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

Calculate week Number from a 4 week cycle

Status
Not open for further replies.

catbert

Technical User
May 1, 2003
56
0
0
GB
Hi,

I am dealing with schedules which vary based on a four week rolling programme. I neeed to display which week we are currently on from current date - and calulate what week exisitng data was collected based on a date.

I have used DATEPART to show the week number from the first full week in Jan 06 but I can't work out a simple formula to convert the week number into 1,2,3 or 4.

For example week commencing 20th Feb is the 8th week - but as part of our rolling cycle it is week 4.

Any help gratefully recieved - thanks!
 
Have a look at the Mod operator.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 


Hi,

You want to look at the DAY of the month

Days 1 - 7 should be Week 1.

So
Code:
WeekNum = Int((Day([MyDate])-1)/7)+1



Skip,
[sub]
[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue][/sub]
 
Thanks for the replies - Skip I can't use the day as day 1 to 7 isn't necessarily in the first week - Week 1 in January starts on the 2nd for instance.

PH I was thinking of using INT or Mod but had a mental block - as you pushed in the right direction I have come up with the solution - WeekNumber MOD 4, gives me what I need

Thanks Again
CB
 


Then use DATEPART to find the starting week for a date. Then use the DAY OFFSET to calculate the week nbr as I described.

Skip,
[sub]
[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top