Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

select where date is > 5 days ago

Posted on 2003-11-11
3
Medium Priority
?
376 Views
Last Modified: 2010-04-17
I'm trying to select (in sql) where a value is > {fn NOW()-5}. That is, matches where the value is greater than 5 days ago, but my function-5 is incorrect. I'd appreciate any suggestions to do this. Thank you.
0
Comment
Question by:cwest1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
pillbug22 earned 500 total points
ID: 9725465
Try the DATEDIFF() function:

SELECT id, name FROM myTable WHERE (DATEDIFF(day, lastUpdated, GETDATE()) <= 5)
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 9725479
edit for above:

"day" is the length of time you are comparing for - can be changed to day, month, week, year, etc.

"lastUpdated" should be the SQL table field you are wanting to compare to today.
0
 

Author Comment

by:cwest1
ID: 9725536
like a charm. thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question