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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Dates into Week numbers 1

Status
Not open for further replies.

DropsIT

MIS
Jun 12, 2003
37
GB
Does anyone know if there is a function that will allocate dates into week nuumbers by either financial year or calender year within a query ?

Thanks
 
I thought that the datepart function may help with this, but I cant remember offhand.

If not, another solution would be to create a calculation that counts that number of days that have elapsed in the current year, and divide that number by 52, and then make an integer of that number.

Something like
=int((date()- dateserial(year(date()-1),12,31)/52)

Hope this helps
 
ooops - sorry - you should be dividing by 7, not 52 in the above example.....and change to number into a positive.

=Int((Date()-DateSerial(Year(Date()-1),12,31))/-7)

 
Bad, its obviously a monday morning!!!

=Int(([ctldate]-DateSerial(Year(Date())-1,12,31))/7)
 
JonoB is right about the DatePart Function
DatePart("ww",[DateField])

"ww" returns the week number


Paul
 
Have just come across this thread and it part solves my problem. however...this solution seems to calculate based on first day of week being Sunday, i need to start my weeks on Monday, how can this be achieved?

Cheers, Craig
Si fractum non sit, noli id reficere
 
From the Access help file on DatePart:

DatePart(interval, date[,firstdayofweek[, firstweekofyear]])

The firstdayofweek argument has these settings:

Constant Value Description
vbUseSystem 0 Use the NLS API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

The firstweekofyear argument has these settings:

Constant Value Description
vbUseSystem 0 Use the NLS API setting.
vbFirstJan1 1 Start with week in which January 1 occurs (default).
vbFirstFourDays 2 Start with the first week that has at least four days in the new year.
vbFirstFullWeek 3 Start with first full week of the year.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top