I need a SQL query to convert 130 minutes into HH:MM:SS format. Can you send me the query to do this please.
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
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.
Dig Deeper on Oracle and SQL
Related Q&A from Rudy Limeback
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback.continue reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clausecontinue reading
Read an example of an SQL case expression from our SQL expert Rudy Limeback.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.