PC Review


Reply
Thread Tools Rate Thread

Access SQL Function to Convert Seconds to HH:MM

 
 
Kayda
Guest
Posts: n/a
 
      27th May 2007
Hi:

I have a number in seconds that I need to convert to an HH:MM string
in Access SQL code. How to do?

Thanks,
Kayda

 
Reply With Quote
 
 
 
 
Kayda
Guest
Posts: n/a
 
      27th May 2007
I found this on an older forum:

Format(Int([Field1]/3600),"00") & ":" & Format(Int(([Field1]-
(Int([Field1]/3600)*3600))/60),"00") & ":" & Format((([Field1] Mod
60)),"00")

and, that works, but I can't just remove the end bit (the "seconds"
bit) as that won't round my minutes(and hours where applicable) i.e.

170 seconds
=00:02:50
=00:02 using this formula
=00:03 using proper rounding

3599 seconds
= 00:59:59
= 00:59 using this formula
= 01:00 using proper rounding

How to do?

Thanks,
Kayda



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      27th May 2007
On 26 May 2007 21:56:42 -0700, Kayda <(E-Mail Removed)> wrote:

>Hi:
>
>I have a number in seconds that I need to convert to an HH:MM string
>in Access SQL code. How to do?


[seconds] \ 3600 & Format([seconds] \ 60 MOD 60, "\:00")

This will discard the seconds. The backslash is an integer divide operator (or
a take-the-next-format-character-literally command).

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert seconds to days, hours, minutes and seconds. Sheldon Microsoft VB .NET 5 6th Jul 2008 03:09 PM
Convert seconds to minutes and seconds in excel =?Utf-8?B?YW5vbnltb3Vz?= Microsoft Excel Worksheet Functions 3 25th Dec 2004 08:38 PM
Formula to Convert Minutes:Seconds to just seconds - Plz read Post Notts_Lad Microsoft Excel Misc 6 27th Jul 2004 12:35 AM
Convert Seconds to Days, Hours and Seconds foramt. WRACK Microsoft VB .NET 5 8th Sep 2003 12:09 AM
Convert seconds into hours:minutes:seconds Jeff Microsoft Excel Worksheet Functions 2 9th Aug 2003 06:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:35 PM.