I need a SQL query to convert 130 minutes into HH:MM:SS format. Can you send me the query to do this please.

    Requires Free Membership to View

Sorry, but the answer is "It depends."

In MySQL, you can say sec_to_time(130*60) and you're done.

In Microsoft SQL Server, you can say convert(char(8),dateadd(n,130,0),108) and you're done.

In Microsoft Access, you can say format(dateadd("n",130,0),"HH:NN:SS") and you're done.

None of these SQL snippets will work in any other database.

Sorry, off the top of my head I don't know how to do this in Oracle, Informix, DB2, Firebird or PostgreSQL. I would have to look up the date and time functions in the manual, to see if I can find any that might be of service. But you can do that too, eh.

This was first published in March 2007

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: