Quantcast
Channel: AutoHotkey Community
Viewing all articles
Browse latest Browse all 579

Ask for Help (v1) • Re: How to calculate Week number with week starting Sunday?

$
0
0

1. What is the output of your script?

2. What output did you expect to see?


Thank you so much mikeyww.

Below is my code:

CODE:

q:: ;list dates with week numbers and weekdays
vDate := 20210101
vOutput := ""
Loop, % 366*5
{
vOutput .= SubStr(vDate, 1, 8) " " Try_YWeek(vDate) " " FormatTime(vDate, "ddd") "`r`n"
vDate := DateAdd(vDate, 1, "D")
}
Clipboard := vOutput
MsgBox, % "done"
return

Esc::ExitApp

; ------------------------------------------------------------------------------

Try_YWeek(vDate:=""){
if (vDate = "")
{
vDate := A_Now
}
vYWeek := FormatTime(vDate, "YWeek")

; return vYWeek
; return Format("{:02}", vYWeek)
return SubStr(vYWeek, 5, 2)
}


Currently it is outputting as:

20211231 52 Fri
20220101 52 Sat
20220102 52 Sun
20220103 01 Mon
20220104 01 Tue
20220105 01 Wed

Where the week starts at Monday. I wish the week to starts at Sunday: (Which is US based system)

20211231 52 Fri
20220101 52 Sat
20220102 01 Sun
20220103 01 Mon
20220104 01 Tue
20220105 01 Wed

How may I achieve that?

Thank you so so much!!!

Statistics: Posted by rc76 — Today, 07:37



Viewing all articles
Browse latest Browse all 579

Trending Articles