Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get week of year for old date 1

Status
Not open for further replies.

Kazendar

Programmer
Oct 23, 2008
18
LB
# to get WeekOfYear we use the following :

get-date -uFormat %W # 1
get-date -uFormat %w # 3

# today is "01/07/2009" MM/DD/YYYY
# but how to get WeekOfYear for old or future date ?
 
get-date -date "7/30/1968" -uFormat %W

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Why are there different results ?
what it is wrong with %w lower-case ?
the value is 4, instead 0 %W with upper-case .

get-date -date "1/1/2009" -uFormat %W # 0 upper-case W
get-date -date "1/1/2009" -uFormat %w # 4 lower-case w
 
Well I can't find it documented, but I suspect that %W is week of the year and %w is day of the week.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
EBGreen you are correct. It actually is documented, see the NOTES section in
Code:
help get-date -full
for that description as well as the other values for the Unix format parameter
 
Very sorry EBGreen, crobin1 and for all.
Should be used %V instead of lower-cases.

Correction:
get-date -date "1/1/2009" -uFormat %V # 1

Documented at PowerShell Help file.
search for Get-Date
.
.
.
Week:
· W Week of the year (00-52)
· V Week of the year (01-53)
· U Same as 'W'
 
Oops. Sure enough. I could have sworn that I checked get-help. I suspect I did -detailed instead of -full. Good catch Crobin1.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top