locked
DatePart(Week, @Date) Returns wrong weeknumber? RRS feed

  • Question

  • Hi,
    I notice the following results of query:
    Declare			@Date1				DateTime
    	,			@Date2				DateTime
    
    Set				@Date1			=	'1/1/2010'
    Set				@Date2			=	'1/4/2010'
    Select			@Date1			As	Jan_1_2010
    	,			DatePart(Week,	@Date1)	WeekJan_1_2010
    	,			@Date2			As	Jan_4_2010
    	,			DatePart(Week,	@Date2)	WeekJan_4_2010
    	,			@@DateFirst		As	DateFirst
    
    Jan_1_2010              WeekJan_1_2010 Jan_4_2010              WeekJan_4_2010 DateFirst
    ----------------------- -------------- ----------------------- -------------- ---------
    2010-01-01 00:00:00.000              1 2010-01-04 00:00:00.000              2         7
    
    (1 row(s) affected)
    
    The weeknumber of 1/1/2010 should be 53 instead of 1
    The weeknumber of 1/4/2010 should be 1 instead of 2
    What can I do to obtain the correct result?
    Thanks in advance, Jos





    Monday, January 11, 2010 8:08 AM

Answers

All replies