Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chaaru_akilan
Starting Member
16 Posts |
Posted - 2012-12-06 : 04:42:07
|
How to skip only Sundays between two dates ?-Thanks |
|
chaaru_akilan
Starting Member
16 Posts |
Posted - 2012-12-06 : 04:47:12
|
Found the solution,DATENAME(DW,@frmDte)= 'Sunday'-Thanks |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-12-06 : 04:51:47
|
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 sundaysCan 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. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-12-06 : 04:53:04
|
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. |
|
|
|
|
|