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.
Author |
Topic |
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2013-06-04 : 16:23:28
|
I have a table tab_RM, has data rm_date(datetime)How to get all data till yesterday upto 11:59PMselect * from tab_RM where rm_date > getdate() -1;Thanks a lot for the helpful info. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-06-04 : 16:42:29
|
[code]SELECT * FROM tab_RM WHERE rm_date < CAST(GETDATE() AS DATE);[/code]This will get you everything prior to today. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-05 : 00:07:11
|
SELECT * FROM tab_RM WHERE rm_date < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)in case you're on an earlier version as DATE datatype is available only from 2008 onwards------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-06-05 : 08:10:26
|
quote: Originally posted by visakh16 SELECT * FROM tab_RM WHERE rm_date < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)in case you're on an earlier version as DATE datatype is available only from 2008 onwards------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
OP asked the question in SL 2008 forum, so it is not unreasonable to infer that he is using SQL 2008. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-05 : 13:50:31
|
quote: Originally posted by James K
quote: Originally posted by visakh16 SELECT * FROM tab_RM WHERE rm_date < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)in case you're on an earlier version as DATE datatype is available only from 2008 onwards------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
OP asked the question in SL 2008 forum, so it is not unreasonable to infer that he is using SQL 2008.
that was the hangover from another post. Didnt realize this is on 2008 forum ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|
|
|