Jump to content

Return day name for year day


Recommended Posts

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.

:graduated:

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

  • Developers

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

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 by BugFix

Best Regards BugFix  

Link to comment
Share on other sites

I have shorten BugFix' code! Posted Image

#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]))
EndFunc

Br,

UEZ

Edited 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...