|
| |
|
|
ScribeVision
Posts: 274 From: None Status: offline
|
How to Compare Dates in SQL Query - 8/3/2004 16:10:44
I created a web site for employees request that coding changes be reviewed before the code is released. The employees are supposed to request this review at least 7 days before releasing their code. So the employee fills out a form to add their request to the database. The database (among other things) captures the date/time the request was entered and the date/time they plan to release the code. After the code is released, the employee goes back and updates the status of their request from the default 'open' to 'comp'. The date/time of the completion update is also captured. Now they want me to create two new queries: - Display all requests that were submitted with less than 7 days lead time before the release date - Display all requests that were not updated to 'comp' within 24 hours of the release date Anybody done something similar that can share how I can phrase the sql in the DRW? Timing is critical because I will be mobilizing with my National Guard unit for duty in Iraq in the next week or so!
|
|
|
|
BeTheBall
Posts: 6336 Joined: 6/21/2002 From: West Point Utah USA Status: online
|
RE: How to Compare Dates in SQL Query - 8/3/2004 16:34:18
You will want to employ the DateDiff function. quote:
- Display all requests that were submitted with less than 7 days lead time before the release date SELECT * FROM Table WHERE DateDiff('d', submitdate, releasedate) < 7 quote:
- Display all requests that were not updated to 'comp' within 24 hours of the release date SELECT * FROM Table WHERE DateDiff('h', releasedate, updatetocompdate) < 24
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|