Pages

Wednesday, June 24, 2009

calculate hour minutes from milliseconds in oracle query

SQL QUERY:

SELECT
SUBSTR(to_char((39600/60/60),'00.00') , 0, INSTR(to_char((39600/60/60),'00.00'), '.', 1, 1)-1) hour,
to_char((SUBSTR(to_char((39600/60/60),'00.00'), INSTR(to_char((39600/60/60),'00.00'), '.', 1, 1),length(to_char((39600/60/60),'00.0'))) *60),'00') as Minutes
FROM dual;

OUTPUT

HOUR MINUTES
------ -------
11 00

1 rows selected

ANOTHER EXAMPLE

SELECT
SUBSTR(to_char((11700/60/60),'00.00') , 0, INSTR(to_char((11700/60/60),'00.00'), '.', 1, 1)-1) hour,
to_char((SUBSTR(to_char((11700/60/60),'00.00'), INSTR(to_char((11700/60/60),'00.00'), '.', 1, 1),length(to_char((11700/60/60),'00.00'))) *60),'00') as Minutes
FROM dual;

OUTPUT

HOUR MINUTES
------ -------
03 15

1 rows selected

No comments:

ShareThis

Welcome

Welcome to Rajesh Prajapati, asp.net blog.
Here you can find some useful code and information about asp.net., c#, VB.net, SQL Server, Web Service, Web Designing etc