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
 Development Tools
 Other Development Tools
 compare datetime with integer

Author  Topic 

mahesh423
Starting Member

9 Posts

Posted - 2008-10-01 : 01:02:29
i have a query in which i need to check for today's date and need to compare it with a date column of a table which is actually integer..

how to get today's date thru getdate() in a varaible in an stored proc..?
after taking tat datetime filed into a variable,so now how to compare a datetime value with int field...?
can anyone please let me kno asap..

Mahesh Kumar

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-01 : 01:30:20
in MS SQL Server you can do like this

SELECT * FROM YourTable WHERE yourintegerdatecolumn=CAST(GETDATE() AS int)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-01 : 01:33:43
Also is your integer column having datetime value in ineger format (ie like 20081101,...) or is it having integer representing date(like 39720,..)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-01 : 02:17:01
What will datetime '20081001 09:00' give integer? 39720
What will datetime '20081001 19:00' give integer? 39721

mahesh, it's better to use
SELECT	DATEDIFF(DAY, '19000101', GETDATE())
to get same integer value for whole day.


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

mahesh423
Starting Member

9 Posts

Posted - 2008-10-07 : 23:02:04
thanks for the reply..
it helped alot..


Mahesh Kumar
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-09 : 03:22:25
quote:
Originally posted by mahesh423

thanks for the reply..
it helped alot..


Mahesh Kumar


But you haven't replied to questions asked

Madhivanan

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

- Advertisement -