We help IT Professionals succeed at work.

DATEDIFF FUNCTION

keplan
keplan asked
on
Medium Priority
580 Views
Last Modified: 2012-05-12
Hi,

Could someone help me to get the folowing answer from datediff function.

I havea two date on my source data, the format is as below:

2008-01-24 00:00:00.000      2008-01-25 00:00:00.000


I want to get the answer = 2 from the datediff.

How do I achieve this?

Thanks.
Comment
Watch Question

Chris MangusDatabase Administrator
CERTIFIED EXPERT
Commented:
Well, this is only a difference of 1 day.  If you must have 2 be the result then use:

Select DateDiff(dd, '2008-01-24 00:00:00.000','2008-01-25 00:00:00.000') + 1

Why do you need 2 as the output?
Commented:
this is count as two days, bcz, my business case, the source is carrying the date range as my example, meaning for the business is two days.
Chris MangusDatabase Administrator
CERTIFIED EXPERT

Commented:
Then my query should work fine.

Author

Commented:
excellent

Author

Commented:
thanks

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