We help IT Professionals succeed at work.

Question on DateDiff query

edrz01
edrz01 asked
on
Medium Priority
365 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?
Comment
Watch Question

Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:
Why dont you make it much simpler

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

Author

Commented:
This is an existing query - I just need to understand what it is doing....
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:
BTW
M is month, use MINUTE or N
Software Engineer
CERTIFIED EXPERT
Commented:
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

Author

Commented:
Thanks!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.