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 |
|
soori457
Yak Posting Veteran
85 Posts |
Posted - 2009-04-13 : 00:50:27
|
| Hai all,I need to retrieve last 30 days data from the current dateEmployee(table)Employee table has date_created(column) of datetime datatypeAny one help me plzzz....Thanks in AdvanceSuresh Kumar |
|
|
soori457
Yak Posting Veteran
85 Posts |
Posted - 2009-04-13 : 00:58:43
|
| I have written a query for thisselect * from Employee where date_created between dateadd(day, datediff(day, 0 ,getdate())-30, 0) and getdate()anyone please tell, it is correct way or not.Suresh Kumar |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-13 : 02:17:30
|
quote: Originally posted by soori457 I have written a query for thisselect * from Employee where date_created between dateadd(day, datediff(day, 0 ,getdate())-30, 0) and getdate()anyone please tell, it is correct way or not.Suresh Kumar
If you want to include today's time too then it is correctMadhivananFailing to plan is Planning to fail |
 |
|
|
soori457
Yak Posting Veteran
85 Posts |
Posted - 2009-04-13 : 02:34:43
|
| Thanks Madhivanan for your reply.If I want only dates but not time, then What should I have to do..Suresh Kumar |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2009-04-13 : 02:46:43
|
| select * from Employee where date_created between dateadd(day, datediff(day, 0 ,getdate())-30, 0) and dateadd(day,datediff(day, 0 ,getdate()), 0) Karthik |
 |
|
|
soori457
Yak Posting Veteran
85 Posts |
Posted - 2009-04-13 : 02:59:53
|
| Thanks KarthikIts working fineSuresh Kumar |
 |
|
|
|
|
|
|
|