Computing Sequential Week Numbers Across Multiple Years

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Computing Sequential Week Numbers Across Multiple Years

Brian Dates
Cheers, everyone.

I have several million service times that I need to summarize by week, from a start date to end date over multiple years beginning with 10/01/2016 and ending 09/30/2021. I need to number the weeks sequentially over the five-year period rather than start over again with Week = 1 on every January 1. Can anyone point me in the direction of syntax that will accomplish this?

Thanks.

Brian
Reply | Threaded
Open this post in threaded view
|

Re: Computing Sequential Week Numbers Across Multiple Years

Art Kendall
Untested may need tweaking.

if you mean calendar weeks
Datetime2 is your date.
Datetime1 is 1/1/2016.

compute TheWeek= 1+ trunc(DATEDIFF(datetime2, datetime1, “weeks”)).

if you mean weeks of service for a case
Datetime2 is date at end of service
Datetime1 is date at beginning of service

compute WeeksOfService= DATEDIFF(datetime2, datetime1, “weeks”).

Or do you mean weeks from start of service that some event takes place?
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Computing Sequential Week Numbers Across Multiple Years

Brian Dates
Art,

Perfect! # 1 was what I wanted. Thank-you!

Brian