Geeks With Blogs

News

Google My Blog

Catch me at: The List!


My InstallScript Utility Belt My Amazon Wishlist
My Standard Disclaimer


Archives
Chris G. Williams Beware: I mix tech and personal interests here.
My good buddy Paul Pearce (Roanoke, VA) shares this relevant tip:
This affects those of you supporting Classic ASP.
 
There is a bug in DatePart that makes it occasionally return the wrong week of the year ("ww")
 
Apparently the first day of the first week of the year returns as week 53 sometimes (3 times per 28 years, once per 400 years)...  
and of course 12/30/2007 is one of those times :)
 
So... pages that figure out the week and period are saying that 12/29 is Per 13, Wk 4, 12/30 is Per 13, Wk 5, and 12/31 is Per 1 Wk 1.
 

Fortunately there is a (not entirely elegant) workaround:  
 
If datepart returns Wk 53, then add 7 days to the date and see what week that returns.
If it returns Wk 2, you know it messed up and you can manually force the value to wk 1.
Posted on Thursday, December 27, 2007 9:28 AM General Interest | Back to top


Comments on this post: if your date starts misbehaving

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Chris G. Williams | Powered by: GeeksWithBlogs.net