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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 I have to find out DATE from start date & end date

Author  Topic 

ranganathanmca
Starting Member

15 Posts

Posted - 2011-08-31 : 02:59:07
Hi Guys.,
I have to find out DATE from start date & end date,i am getting input from the user date i need to find out if start date & end date in between date is there are not

Example date
start Date End Date
08/01/2011 08/10/2011
08/15/2011 08/25/2011

Please guide to reslove this problem

Thanks

ranganathan palanisamy

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-31 : 03:03:03
[code]
SELECT *
FROM yourtable
WHERE start_date <= @user_date
and end_date >= @user_date
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-31 : 03:07:44
or is it?

SELECT *
FROM yourtable
WHERE @User_date BETWEEN start_date AND end_date


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-08-31 : 04:15:11
It depends. If StartDate and EndDate are of datetime datatype, the two queries above will work.
If not, you need to convert the two columns to DATE before doing anything else.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -