Jai
Jai

Reputation: 11

Datediff function in Access Database

I am trying to use Datediff function while subtracting two dates. One date is with Date and time stamp and the other with date only. How to get the difference of dates?

Here Column1 is 7/11/2017 4:24:38 PM and Column2 is 15/12/2017 where there is no timestamp.

DateDiff("d",[Column1],[Column2])

Upvotes: 0

Views: 900

Answers (1)

jose_bacoy
jose_bacoy

Reputation: 12684

Convert the date column into datetime using Format function. See example below. EDIT: since you want the difference in days and decimal point, I get the difference in hours then divide by 24. You can be as accurate if you want by getting the difference in minutes or seconds but using a different divisor.

SELECT DateDiff("h",
       Now(),
       Format('04/05/2018','mm/dd/yyyy hh:nn:ss'))/24 AS Expr1;

result: 1.125 days

Upvotes: 1

Related Questions