Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
How to comapre the date columns and datetime variable/getdate() value in where clause which are differing by seconds there by query doesnt return any rows.how to canvert both the values.
my requirement is as followsdeclare @dateVal datetimedeclare @init intset @dateVal=getdate()set @init=1 --represents the how many days old data requiredselect * from TabHistorywhere CreatedOn=dateadd(dd,@init*-1,@dateVal)
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2009-10-13 : 02:19:00
the following query will gives you CreateOn @init days ago