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 - 2014-01-15 : 22:18:28
|
Hi, I would like to know, is there is any difference between Option 1 and Option 2 or not?Option 1Declare @StartDate DateDeclare @EndDate DateSet @StartDate = '20140115'Set @EndDate = '20140114'Option 2Declare @StartDate DateDeclare @EndDate DateSet @StartDate = '20140114'Set @EndDate = '20140115' |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-01-16 : 00:33:47
|
ah.. spot the differenceYes. The value for @StartDate and @EndDate for option 1 is reversed for option 2 KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-16 : 05:08:06
|
quote: Originally posted by tooba Hi, I would like to know, is there is any difference between Option 1 and Option 2 or not?Option 1Declare @StartDate DateDeclare @EndDate DateSet @StartDate = '20140115'Set @EndDate = '20140114'Option 2Declare @StartDate DateDeclare @EndDate DateSet @StartDate = '20140114'Set @EndDate = '20140115'
depends on what you use them for.Explain us how you're planning to use these values------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-01-16 : 12:14:11
|
As khtan pointed out, the @StartDate and @EndDate are reversed in one versus the other. I would venture a guess that the second option is the right one, because more often than not, start date comes before the end date. Of course, there can be exceptions. |
|
|
|
|
|