HKFuey
asked on
VBA Date syntax
VBA Syntax
I have this line: Format(Date, "YYWW") but in January (e.g. 31/01/2019) this returns '195' week 5 is a single digit.
For single number weeks I need it to be in 2 digits so wee 5 would be '05'
Anyone know how?
I have this line: Format(Date, "YYWW") but in January (e.g. 31/01/2019) this returns '195' week 5 is a single digit.
For single number weeks I need it to be in 2 digits so wee 5 would be '05'
Anyone know how?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this.
Format(Date, "YY") & Format(DatePart("WW", Date), "00")
ASKER
Hi Alan, that gives me single digit weeks early in the year.
Hi Ryan, that worked with minor adjustment: -
YrWk = Format(Date, "YY") & Right("0" & Format(Date, "WW"), 2)
Hi Ryan, that worked with minor adjustment: -
YrWk = Format(Date, "YY") & Right("0" & Format(Date, "WW"), 2)
ASKER
Hi Norrie, I think we 'cross posted'. Thank you for your input.
Format(Date, "YY") & Format(Date, "WW")
Alan.