user3114347
user3114347

Reputation: 369

Count total days between current day (SQL)

i'm trying to count the total days between current date and a specific column called "DayConfirm" (datetime). I want to show the total days in a new column beside the rows with "DayChanged" So far i got this:

SELECT DATEDIFF(CURDATE(),(DayConfirm, '%m/%d/%Y') AS DAYS
FROM Administr

can anyone help me? Thank you in advance.

Upvotes: 9

Views: 31628

Answers (2)

Christos
Christos

Reputation: 53958

You could try to make use of DATEDIFF:

SELECT DATEDIFF(DAY, GETDATE() , DayConfirm) 

Upvotes: 8

Zaheer Ahmed
Zaheer Ahmed

Reputation: 28548

Your need to pass Date Part ie day here attribute:

SELECT DATEDIFF(day,'2008-06-05','2008-08-05') AS DiffDate

also you missing the closing ); try this:

SELECT DATEDIFF(day, CURDATE(),(DayConfirm, '%m/%d/%Y')) AS DAYS
FROM Administr

Upvotes: 0

Related Questions