sunday is my week ending day

Hi All,

When I use DATEDIFF(week, '6/1/2010', '6/6/2010') the answer I expect should 
be 0 because I consider Sunday my week ending day. The answer I get is 1 
which is incorrect in my situation.

How would I adjust for this?

Thanks,
rodchar
0
Utf
6/1/2010 1:27:01 PM
sqlserver.programming 1873 articles. 0 followers. Follow

3 Replies
571 Views

Similar Articles

[PageSpeed] 10

You can use SET DATEFIRST  to change first day of the week and check it's 
current value using  SELECT @@DATEFIRST.
But I think algorithm if DATEDIFF does not take it into account. Instead you 
can count number of days and divide it by 7.

"rodchar" <rodchar@discussions.microsoft.com> wrote in message 
news:B0DC77EB-7C88-48A1-93C8-E36B1926B41E@microsoft.com...
> Hi All,
>
> When I use DATEDIFF(week, '6/1/2010', '6/6/2010') the answer I expect 
> should
> be 0 because I consider Sunday my week ending day. The answer I get is 1
> which is incorrect in my situation.
>
> How would I adjust for this?
>
> Thanks,
> rodchar 


0
Maria
6/1/2010 2:01:59 PM
Use integer division

SELECT	DATEDIFF(DAY, 0, '6/6/2010') / 7 - DATEDIFF(DAY, 0, '6/1/2010') / 7

//Peso


"rodchar" <rodchar@discussions.microsoft.com> wrote in message 
news:B0DC77EB-7C88-48A1-93C8-E36B1926B41E@microsoft.com...
> Hi All,
>
> When I use DATEDIFF(week, '6/1/2010', '6/6/2010') the answer I expect 
> should
> be 0 because I consider Sunday my week ending day. The answer I get is 1
> which is incorrect in my situation.
>
> How would I adjust for this?
>
> Thanks,
> rodchar 

0
Peso
6/1/2010 3:06:49 PM
thanks all for the help,

rod.

"rodchar" wrote:

> Hi All,
> 
> When I use DATEDIFF(week, '6/1/2010', '6/6/2010') the answer I expect should 
> be 0 because I consider Sunday my week ending day. The answer I get is 1 
> which is incorrect in my situation.
> 
> How would I adjust for this?
> 
> Thanks,
> rodchar
0
Utf
6/1/2010 5:26:01 PM
Reply:

Similar Artilces: