Datepart year 2004 vs. 2005

G

Guest

I am using the datepart function to create a number that consist of year and
week number. I have however problems since January 1 and 2 return year 2005
and week 53. I have tried the different datepart parameters, but with out
success:

I use:
CreateWeek:
DatePart("yyyy";[dbo_Invhead]![Created];"2";"2")*100+DatePart("ww";[dbo_Invhead]![Created];"2";"2")

01-jan-2005 and 02-jan-2005 returns 200553, but I want it to return 200453
like 31-dec-2004 does.

Any ideas on how to solve this.

Thank you
Peter
 
D

Douglas J. Steele

Since the year IS 2005 for both of those dates, there's no way to return
anything else.

You'll have to put in logic to check if the weeknumber is greater than 52
and deduct one from the year if it is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top