SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Skip only Sunday
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chaaru_akilan
Starting Member

India
16 Posts

Posted - 12/06/2012 :  04:42:07  Show Profile  Reply with Quote
How to skip only Sundays between two dates ?

-Thanks

chaaru_akilan
Starting Member

India
16 Posts

Posted - 12/06/2012 :  04:47:12  Show Profile  Reply with Quote
Found the solution,
DATENAME(DW,@frmDte)= 'Sunday'

-Thanks
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/06/2012 :  04:51:47  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Count number of days.
subtract 7 * number of weeks.
Depends on where your week starts - if it is a sunday that should be correct - if not might need to be amended using start and end date days.

Other option - start at start date and count 1 for each day omitting sundays
Can be done easily using a cte.

If you have a date table which includes the day name you can just join to that. That would be a good idea if you need this sort of calculation because you will probably have to deal with bank holidays and such at some point.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/06/2012 :  04:53:04  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
quote:
Originally posted by chaaru_akilan

Found the solution,
DATENAME(DW,@frmDte)= 'Sunday'

-Thanks



That will just tell you if the start date is a sunday - not if there are sundays between the two dates.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000