How would you calculate the difference between two dates?

How would you calculate the difference between two dates?

use DATEDIFF(datepart,startdate,enddate)
the datepart is the part of the date you want the difference of, days, months, years.

so apparently i do something like ..
SELECT DATEDIFF(dd, '12/5/2002 22:00', '12/6/2002 09:00')

can i do something like
SELECT DATEDIFF(dd, DateOfRego, CaseClosed)

so apparently i do something like ..
SELECT DATEDIFF(dd, '12/5/2002 22:00', '12/6/2002 09:00')

can i do something like
SELECT DATEDIFF(dd, DateOfRego, CaseClosed)

you can do that, so long as you assign appropriately either pl-sql, PHP or ASP. What are you running on??

sample...
DateOfRego="12/5/2002 22:00"
CaseClosed="12/6/2002 09:00"


SELECT DATEDIFF(dd, '" & DateOfRego & "', '" & CaseClosed & "')

DateOfRego="12/5/2002 22:00"
CaseClosed="12/6/2002 09:00"

What if thet are based simply on dates, no times?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.