If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > SQL Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-30-11, 12:30
math123 math123 is offline
Registered User
 
Join Date: Apr 2011
Posts: 8
SQL Query

Can anybody help me in retrieving the data from specified date to 30 days ago in sql. I tried using [date] >= dateadd(d,datediff(d,0,'2011-03-28'),-30),, but its retrieving records till current date. I want to retrieve data only till 28 march from 30 days ago i.e. 28 Feb or 1st march.

Welcome for all suggestions
Reply With Quote
  #2 (permalink)  
Old 04-30-11, 13:28
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
WHERE datetimecolumn BETWEEN DATEADD(D,-30,'2011-03-28') AND '2011-03-28'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-01-11, 07:43
math123 math123 is offline
Registered User
 
Join Date: Apr 2011
Posts: 8
thankyou

Ya. It worked well. Thank you
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On