Access query and Sum Total of Time in Decimal. How to change to Time Format?

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Please help me achieve this.
When i run query i get Total Time in Decimals... HOw can i get it in Time Format as in HH:MM:SS.

Thanks in advance.
Code:
[/FONT]
[FONT=Courier New]SELECT Table1.[Login Date], Sum(Table1.[Total Time]) AS [SumOfTotal Time]
FROM Table1
GROUP BY Table1.[Login Date];

Current:
<TABLE cellSpacing=0 bgColor=#ffffff border=1><CAPTION>Query1</CAPTION><THEAD><TR><TH borderColor=#000000 bgColor=#c0c0c0>Login Date</TH><TH borderColor=#000000 bgColor=#c0c0c0>SumOfTotal Time</TH></TR></THEAD><TBODY><TR vAlign=top><TD borderColor=#d0d7e5>10Jan12</TD><TD borderColor=#d0d7e5 align=right>1.04166666666667E-03</TD></TR><TR vAlign=top><TD borderColor=#d0d7e5>30Dec11</TD><TD borderColor=#d0d7e5 align=right>0.337465277777778</TD></TR><TR vAlign=top><TD borderColor=#d0d7e5>31Dec11</TD><TD borderColor=#d0d7e5 align=right>4.93287037037037E-02</TD></TR></TBODY><TFOOT></TFOOT></TABLE>

Result Expected:
<TABLE style="WIDTH: 109pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=145 border=0><COLGROUP><COL style="WIDTH: 42pt; mso-width-source: userset; mso-width-alt: 2048" width=56><COL style="WIDTH: 67pt; mso-width-source: userset; mso-width-alt: 3254" width=89><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl64 style="BORDER-RIGHT: black 0.5pt solid; BORDER-TOP: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; WIDTH: 42pt; BORDER-BOTTOM: black 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: silver" width=56 height=17>Login Date</TD><TD class=xl66 style="BORDER-RIGHT: black 0.5pt solid; BORDER-TOP: black 0.5pt solid; BORDER-LEFT: black; WIDTH: 67pt; BORDER-BOTTOM: black 0.5pt solid; BACKGROUND-COLOR: silver" width=89>SumOfTotal Time</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl65 style="BORDER-RIGHT: silver 0.5pt solid; BORDER-TOP: silver 0.5pt solid; BORDER-LEFT: silver 0.5pt solid; WIDTH: 42pt; BORDER-BOTTOM: silver 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=56 height=17>10Jan12</TD><TD class=xl67 style="BORDER-RIGHT: silver 0.5pt solid; BORDER-TOP: silver 0.5pt solid; BORDER-LEFT: silver; WIDTH: 67pt; BORDER-BOTTOM: silver 0.5pt solid; BACKGROUND-COLOR: transparent" width=89>0:01:30</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl65 style="BORDER-RIGHT: silver 0.5pt solid; BORDER-TOP: silver; BORDER-LEFT: silver 0.5pt solid; WIDTH: 42pt; BORDER-BOTTOM: silver 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=56 height=17>30Dec11</TD><TD class=xl67 style="BORDER-RIGHT: silver 0.5pt solid; BORDER-TOP: silver; BORDER-LEFT: silver; WIDTH: 67pt; BORDER-BOTTOM: silver 0.5pt solid; BACKGROUND-COLOR: transparent" width=89>8:05:57</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl65 style="BORDER-RIGHT: silver 0.5pt solid; BORDER-TOP: silver; BORDER-LEFT: silver 0.5pt solid; WIDTH: 42pt; BORDER-BOTTOM: silver 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=56 height=17>31Dec11</TD><TD class=xl67 style="BORDER-RIGHT: silver 0.5pt solid; BORDER-TOP: silver; BORDER-LEFT: silver; WIDTH: 67pt; BORDER-BOTTOM: silver 0.5pt solid; BACKGROUND-COLOR: transparent" width=89>1:11:02</TD></TR></TBODY></TABLE>

 
Do you have times more than 24 hours but you still want to display them as hh:mm?

If you do try [hh]:mm for the format.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Do you have times more than 24 hours but you still want to display them as hh:mm?

If you do try [hh]:mm for the format.

MsgBox Format(1.49487268518714, "[hh]:mm")
returned :12

what 'm exactly doing now is...

submit to database
totaltimeinminutes = DateDiff("n", [starttime], [stoptime])
display user their total login hours in day/month in
totaltimetxt = [totaltimeinminutes] \ 60 & Format([totaltimeinminutes] Mod 60, "\:00")

Thanks again....
 
Upvote 0
Pedie

login hours in months and days?
 
Upvote 0
login hours in months and days?

Yes, in the frontend form, users can see their login hours in days and even for the month...

****** http-equiv="Content-Language" content="en-us"><STYLE type=text/css>.style1 { border-width: 0px;}.style2 { border-style: solid; border-width: 1px;}</STYLE><TABLE style="WIDTH: 41%" class=style1><TBODY><TR><TD style="WIDTH: 214px" class=style2>Total Login Hours (Day)</TD><TD class=style2>7:00:00</TD></TR><TR><TD style="WIDTH: 214px" class=style2>Total Login Hours (This Month)</TD><TD class=style2>29:00:00</TD></TR></TBODY></TABLE>
 
Upvote 0

Forum statistics

Threads
1,221,810
Messages
6,162,108
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top