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 |
|
chongy2
Starting Member
2 Posts |
Posted - 2008-11-21 : 11:32:54
|
| I am using MS Visual Studio tool and need to get information between 01 Jan and 31 Jul every year. I have an end date column for 31 July every year but no column for 01 Jan. I can only use exsiting column so I try to use end date minus 212 days to get 01 Jan but doesnt work.Could anyone help?dont think I explained very well so if you need more info, I am happy happy to provide.Thanks in advance for any suggestions.Chongy |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-21 : 11:54:56
|
| [code]select fields from yourtable where datefield between DATEADD(yy,DATEDIFF(yy,0,EndDate),0) AND DATEADD(dd,1,EndDate)[/code]assuming EndDate doesnt have time part, else[code]select fields from yourtable where datefield between DATEADD(yy,DATEDIFF(yy,0,EndDate),0) AND EndDate[/code] |
 |
|
|
chongy2
Starting Member
2 Posts |
Posted - 2008-11-27 : 06:33:48
|
| Dear visakh16Thanks for your reply. It's sorted out now using DATEADD.Thanks for your help.Chongy2 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-27 : 08:36:51
|
No problem you're welcome |
 |
|
|
|
|
|