Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Apr 10, 2000

Date Subtraction

Question:
I have a date field store in one of my database tables. How do I pull a record from that table within seven days of today's date?
today's date - 7 days

Answer:
To do this, you can use the DateAdd function, but add -7 to the date you want. Here's an example:

DateAdd('d', -7, getdate())
This will add -7 days to the current date.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date