DateDiff using SQL Query

Hi all,

I have a table which has 2 columns Start Time and End Time both columns are formatted as Date/Time Short Time. i.e

Start Time    End Time   Duration
00:00           00:00        00:00

I would like to use the columns to calculate the Duration column however I am not having much success. I am trying to use a SQL Query which looks like the below:

SELECT DATEDIFF([StartTime],[EndTime]) as Duration FROM [DailyTaskLog]

I am sure that I have use something simular to this and it has work however I am having a complete mind blank and am not sure what I am doing wrong.

Kind Regards
SS
SerinaStarAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
You need to specify an Interval .... example Minutes below (n).


SELECT DATEDIFF( "n", [StartTime],[EndTime]) as Duration FROM [DailyTaskLog]
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
Interval Settings (from Help)

yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
0
 
Dale FyeCommented:
To get the number of minutes between the two times, use:

SELECT DateDiff("n", [StartTime], [EndTime]) as Duration-Min FROM [DailyTaskLog]

0
 
danishaniConnect With a Mentor Commented:
In addtion to correct statement of DatabaseMX, if you want a more complete DateDiff function, check below thread out:
http://www.accessmvp.com/djsteele/Diff2Dates.html

Hope this helps,
Daniel
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.