Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Date Help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tooba
Posting Yak Master

224 Posts

Posted - 01/15/2014 :  22:18:28  Show Profile  Reply with Quote
Hi,

I would like to know, is there is any difference between Option 1 and Option 2 or not?

Option 1
Declare @StartDate Date
Declare @EndDate Date

Set @StartDate = '20140115'
Set @EndDate = '20140114'

Option 2
Declare @StartDate Date
Declare @EndDate Date

Set @StartDate = '20140114'
Set @EndDate = '20140115'

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 01/16/2014 :  00:33:47  Show Profile  Reply with Quote
ah.. spot the difference

Yes.

The value for @StartDate and @EndDate for option 1 is reversed for option 2


KH
Time is always against us

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 01/16/2014 :  05:08:06  Show Profile  Reply with Quote
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 1
Declare @StartDate Date
Declare @EndDate Date

Set @StartDate = '20140115'
Set @EndDate = '20140114'

Option 2
Declare @StartDate Date
Declare @EndDate Date

Set @StartDate = '20140114'
Set @EndDate = '20140115'



depends on what you use them for.
Explain us how you're planning to use these values

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 01/16/2014 :  12:14:11  Show Profile  Reply with Quote
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.
Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000