If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > using dateadd to convert int to mm:ss

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-23-11, 10:41
GJBushman GJBushman is offline
Registered User
 
Join Date: Aug 2011
Location: Washington, DC
Posts: 3
using dateadd to convert int to mm:ss

I need to convert an interger to mm:ss. The value, duration, is stored in seconds as an int, 123456. This should be translated as 123.456 seconds. On select I need to convert that to mm:ss. For my purposes I can truncate everything to the right of the decimal. Is dateadd the right approach here? I'm not an SQL expert, just a weeny writing reports. Thanks for any help you can provide.

Jamie
Reply With Quote
  #2 (permalink)  
Old 08-31-11, 17:48
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
?
select right(convert(char(8),dateadd(ss,123456/1000,''),108),5)
Reply With Quote
  #3 (permalink)  
Old 09-01-11, 08:54
GJBushman GJBushman is offline
Registered User
 
Join Date: Aug 2011
Location: Washington, DC
Posts: 3
dateadd

This work! Thank you.
Reply With Quote
Reply

Tags
dateadd, mm:ss

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On