467,074 Members | 1,070 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

Converting information from days to hours and minutes

I have a table where I have fields name START DATE and SHUT OFF DATE with the data type at Date/Time and it's format set to General Date so that I can record both date and time of starting and shutting off. I created a query that I added an expression [SHUT OFF DATE] - [START DATE] to figure out total time the irrigation system was running - it gave its answer in days - how can I convert this answer to hours and minutes instead?
Jul 29 '08 #1
  • viewed: 1394
Share:
3 Replies
missinglinq
Expert 2GB
You need to get elapsed time in minutes (I'm assuming that's as fine as you want to cut it) using DateDiff(), then parse it out, something like this:

Expand|Select|Wrap|Line Numbers
  1. TotalMinutesElapsed = DateDiff("n",[Start Date], [Shut Off  Date])
  2. HoursElapsed = TotalMinutesElapsed\60
  3. MinutesElapsed = TotalMinutesElapsed mod 60
  4.  
Be sure to notice the back slash in the HoursElapsed formula. This causes Access to return only the interger (hours) portion of the division.

Welcome to Bytes!
Linq ;0)>
Jul 29 '08 #2
Thanks a bunch. I have limited knowledge of coding - where would I enter the DateDiff() and the code following it - in the query, right? Sorry for my limited knowledge and thanks for your help
Aug 12 '08 #3
100+
If you want to use query you can try with Format function.
in the field having formula [HTML][Shut Off Date]-[Start Date][/HTML]
try replacing with [HTML]Format([Shut Off Date]-[Start Date];"hh:mm:ss")[/HTML]
Note that depending on regional settings you might need to replace semicolon (;) with comma (,)
Also hh:mm:ss is used for hours:minutes:seconds format so you might want to play with that too.
Aug 12 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Hans [DiaGraphIT] | last post: by
19 posts views Thread by Ricardo Perez Lopez | last post: by
6 posts views Thread by Harlin Seritt | last post: by
2 posts views Thread by Harlin Seritt | last post: by
1 post views Thread by baneaic@yahoo.com | last post: by
realin
4 posts views Thread by realin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.