?
Solved

Question on DateDiff query

Posted on 2012-08-13
5
Medium Priority
?
345 Views
Last Modified: 2012-08-13
Sorry for the easy question but need to verify this part of an existing query.

( DATEDIFF(d,Getdate(),Datetime) >=0 and
DATEDIFF(m,Getdate(),Datetime)<=60)

Is this looking at the current day and the last 60 minutes?
0
Comment
Question by:edrz01
  • 3
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 38288736
Why dont you make it much simpler

DATEDIFF(MINUTE, Getdate(), MyDatetime) <= 60
0
 

Author Comment

by:edrz01
ID: 38288745
This is an existing query - I just need to understand what it is doing....
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 38288752
BTW
M is month, use MINUTE or N
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 1000 total points
ID: 38288769
Ok
DATEDIFF(d,Getdate(),Datetime) >=0
This ensures that the date is at least today

DATEDIFF(m,Getdate(),Datetime)<=60)
This gets data that is 60 months old from today
0
 

Author Closing Comment

by:edrz01
ID: 38288776
Thanks!
0

Featured Post

Industry Leaders: 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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

840 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