Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting Time to an Integer 1

Status
Not open for further replies.

MontgomeryPete

Instructor
Apr 3, 2004
57
US
I have converted elapsed time into hours and minutes by using the DateDiff function and then the result into total minutes by using the Hour and Minute functions. This gives me total elpased minutes.

However, when I attempt to add the result, for example by unit, I get a data type mismatch message. I tried to convert the result using CINT, but still get the same message.

What is the best method to get the elapsed minutes to convert to an integer so that I can perform SUM, etc?

Thanks for your help.

Pete

 
Dates and times are stored as floating point numbers. The best way to add times is to "add the values". The best way to find the difference between times is to "subtract the values". You can use the DateDiff() function which works very well and allows you to specify the interval.


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Try something like this
Code:
SELECT SUM(DateDiff("n",[Date1],[Date2])) AS SumMinutesDifference
FROM Table1;
 
Thank you Duane and IT4EVR for your prompt and helpful responses. DateDiff is very valuable now that I understand it better.

Pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top