supersonic Posted November 4, 2010 Share Posted November 4, 2010 Hi everybody! Is there a way to return a day name (1 to 7, Monday to Sunday) for a year day (1 to 365, resp. 366)? For any given year and/or year day. Currently I'm messing around with DATE.AU3 but without luck... Anyone any idea? Greets, -supersonic. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 4, 2010 Share Posted November 4, 2010 1. Get the Julian date of the first day of the given year with _DateToDayValue() 2. Add your annual Julian date - 1 to that to get the full Julian date (days since noon January 1, 4713 BC) 3. Convert to Gregorian date with _DayValueToDate() 4. Use the Gregorian date to get the day of the week with _DateToDayOfWeek() Sounds awkward, so maybe someone knows a shortcut. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Developers Jos Posted November 4, 2010 Developers Share Posted November 4, 2010 I am not sure what the thing is you are looking for but when you know what day 1 is you also know what day 8, 15 ,22 etc is. Maybe you could first exactly explain what your input is and what result you expect. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BugFix Posted November 4, 2010 Share Posted November 4, 2010 (edited) You can do it so: #Include <Date.au3> ConsoleWrite(_DayInYearToWeekDay(2010, 60) & @CRLF) Func _DayInYearToWeekDay($iYear, $iDayNumber, $fRetAsStr=True) Local $sDate = _DateAdd('D', $iDayNumber -1, $iYear & '/01/01') Local $aDate = StringSplit($sDate, '/', 2) If Not $fRetAsStr Then Return _DateToDayOfWeekISO($aDate[0], $aDate[1], $aDate[2]) Switch _DateToDayOfWeekISO($aDate[0], $aDate[1], $aDate[2]) Case 1 Return 'Monday' Case 2 Return 'Tuesday' Case 3 Return 'Wednesday' Case 4 Return 'Thursday' Case 5 Return 'Friday' Case 6 Return 'Saturday' Case 7 Return 'Sonday' EndSwitch EndFunc ??? - Whats that? - It's impossible to set tags. Edited November 4, 2010 by BugFix Best Regards BugFix Link to comment Share on other sites More sharing options...
UEZ Posted November 4, 2010 Share Posted November 4, 2010 (edited) I have shorten BugFix' code! #include <Date.au3> ConsoleWrite(_DayInYearToWeekDay(2010, 100) & @CRLF) Func _DayInYearToWeekDay($iYear, $iDayNumber, $fRetAsStr = True) Local $sDate = _DateAdd('D', $iDayNumber -1, $iYear & '/01/01') Local $aDate = StringSplit($sDate, '/', 2) If Not $fRetAsStr Then Return _DateToDayOfWeek($aDate[0], $aDate[1], $aDate[2]) Return _DateDayOfWeek(_DateToDayOfWeek($aDate[0], $aDate[1], $aDate[2])) EndFuncBr,UEZ Edited November 5, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
supersonic Posted November 4, 2010 Author Share Posted November 4, 2010 I always have problems getting "date things" right Thank you so far, the code examples and explanations working fine! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now