Author |
Topic |
siumui
Yak Posting Veteran
54 Posts |
Posted - 2012-04-04 : 15:02:15
|
Hello all,I have to retrieve records based on date. I have to pull all records for each day starting 9/1/2011 to the current date, which is today.I'm stuck and I don't even know where to begin.Please help.Thank you.siumui |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2012-04-04 : 15:03:37
|
SELECT someColumns from yourTable WHERE dateField >= '20110901'; |
|
|
siumui
Yak Posting Veteran
54 Posts |
Posted - 2012-04-04 : 15:25:20
|
quote: Originally posted by russell SELECT someColumns from yourTable WHERE dateField >= '20110901';
Thank you. It's that simple and I forgot (sigh...)siumui |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2012-04-04 : 15:48:08
|
You're welcome. We all need a jump-start sometimes |
|
|
X002548
Not Just a Number
15586 Posts |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2012-04-04 : 16:21:26
|
ok, you're right IF there are records with a date later than today |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-04 : 18:17:26
|
better to add it too as we dont know which table we're dealing...it may contain futuristic values like case of forecast,budget etc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2012-04-04 : 19:16:25
|
quote: Originally posted by visakh16 better to add it too as we dont know which table we're dealing...it may contain futuristic values like case of forecast,budget etc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Or just outright bad data sometimes |
|
|
X002548
Not Just a Number
15586 Posts |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-04-17 : 06:03:59
|
ORSELECT someColumns from yourTable WHERE dateField >= '20110901' AND < dateadd(day,datediff(day,0,getdate()),1)MadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-17 : 13:11:20
|
quote: Originally posted by madhivanan ORSELECT someColumns from yourTable WHERE dateField >= '20110901' AND dateField < dateadd(day,datediff(day,0,getdate()),1)MadhivananFailing to plan is Planning to fail
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-04-18 : 05:48:35
|
quote: Originally posted by visakh16
quote: Originally posted by madhivanan ORSELECT someColumns from yourTable WHERE dateField >= '20110901' AND dateField < dateadd(day,datediff(day,0,getdate()),1)MadhivananFailing to plan is Planning to fail
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Thanks MadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-19 : 01:12:53
|
np ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|