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 |
tooba
Posting Yak Master
224 Posts |
Posted - 2013-04-18 : 00:41:56
|
Hi Guys, Need date syntax help. Here what i want. I have two VariableDeclare @StartDate DatetimeDeclare @EndDate DatetimeSet @EndDate = Getdate()Set @StartDate = ?What i want for @StartDate, If i run this report today my @StartDate would be 1/1/2013 and @Enddate would be getdate(). If i run same report in Feb/2014 my @StartDate should be 1/1/2014. Please help me with the syntax.Thank You in advance. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-18 : 01:49:33
|
[code]Declare @StartDate DatetimeDeclare @EndDate DatetimeSELECT @StartDate = DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0),@EndDate = DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)SELECT @StartDate,@EndDate[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
tooba
Posting Yak Master
224 Posts |
Posted - 2013-04-18 : 21:02:44
|
Thanks Visakh... |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-19 : 02:51:30
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|
|
|