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 2005 Forums
 Transact-SQL (2005)
 how can i know the date ?

Author  Topic 

inbs
Aged Yak Warrior

860 Posts

Posted - 2009-04-12 : 08:16:15
if i have to dates like :

5-4-09 and 30-4-09

how can i know if 7-4-09 was between the dates?

cshah1
Constraint Violating Yak Guru

347 Posts

Posted - 2009-04-12 : 08:28:27
??? I am sorry what's your questiono as ther is no DDL but

WHERE youdatecolumn >= '5-4-09' AND youdatecolumn < = '30-4-09'

or you can use BETWEEN







Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-12 : 13:21:12
if your both the fields are of datetime just like below


SELECT CASE WHEN @date BETWEEN date1 AND date2 THEN 'Yes' ELSE 'No' END

@date is paased value (in your ex 7-4-09)

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-13 : 02:57:39
Also use proper datetime datatype and express dates in YYYYMMDD format

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -