Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««12345

A Simple Formula to Calculate the ISO Week Number Expand / Collapse
Author
Message
Posted Saturday, July 27, 2013 3:40 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 16, 2014 4:11 AM
Points: 2,397, Visits: 3,416
Yes, I did indeed. However, the time at my place was 3 am and time to go to bed...

Here is a further reduced code (one less addition)
(DATEPART(DAYOFYEAR, DATEADD(DAY, DATEDIFF(DAY, '17530101', @Date) / 7 * 7, '17530104')) + 6) / 7

My blog about this is here.
If you don't read Swedish well, use either Bing or Google.



N 56°04'39.16"
E 12°55'05.25"
Post #1478275
Posted Saturday, July 27, 2013 10:25 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 12:08 AM
Points: 35,366, Visits: 31,901
SwePeso (7/27/2013)
Yes, I did indeed. However, the time at my place was 3 am and time to go to bed...

Here is a further reduced code (one less addition)
(DATEPART(DAYOFYEAR, DATEADD(DAY, DATEDIFF(DAY, '17530101', @Date) / 7 * 7, '17530104')) + 6) / 7

My blog about this is here.
If you don't read Swedish well, use either Bing or Google.


Thanks, Peter. I'll check out the formula.

My question was based on the fact that we weren't receiving each other's emails in the past.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1478295
« Prev Topic | Next Topic »

Add to briefcase «««12345

Permissions Expand / Collapse