Home » Developer & Programmer » Forms » Days, Hours, Min and Seconds Calculation (oracle 10g, windows XP)
Days, Hours, Min and Seconds Calculation [message #481686] Fri, 05 November 2010 05:20 Go to next message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
Dear All
I am able to run this query in Sql Prompt.

DEFINE Today = TO_DATE('03.12.2004:10:34:24','DD.MM.YYYY:HH24:MI:SS')

SELECT TO_CHAR(hiredate,'DD.MM.YYYY:HH24:MI:SS') "Hiredate",
TO_CHAR(&Today,'DD.MM.YYYY:HH24:MI:SS') "Today",
trunc(86400*(&Today-hiredate))-60*(trunc((86400*(&&Today-hiredate))/60)) "Sec",
trunc((86400*(&Today-hiredate))/60)-60*(trunc(((86400*(&&Today-hiredate))/60)/60)) "Min",
trunc(((86400*(&Today-hiredate))/60)/60)-24*(trunc((((86400*(&&Today-hiredate))/60)/60)/24)) "Hrs",
trunc((((86400*(&Today-hiredate))/60)/60)/24) "Days"
FROM emp;

It gives proper / desired results.
I want to use it on my Form, how can it be done?
any help is appreciated.

regards.
Re: Days, Hours, Min and Seconds Calculation [message #481688 is a reply to message #481686] Fri, 05 November 2010 05:25 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
What is stopping you using it in your form?
It's just a query, what's so difficult about including it?
Re: Days, Hours, Min and Seconds Calculation [message #481690 is a reply to message #481688] Fri, 05 November 2010 05:32 Go to previous messageGo to next message
myclassic
Messages: 136
Registered: December 2006
Location: Pakistan
Senior Member
cookiemonster wrote on Fri, 05 November 2010 05:25
What is stopping you using it in your form?
It's just a query, what's so difficult about including it?


DEFINE is stopping me.
this query will not run without DEFINE reserved.
where this DEFINE key word will be defined ???
Re: Days, Hours, Min and Seconds Calculation [message #481693 is a reply to message #481690] Fri, 05 November 2010 05:39 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
DEFINE is a sqlplus command for declaring variables. You know how to declare variables in forms don't you?

Also that query is way too complicated. This is a simpler version:
SQL> SELECT to_char(hiredate, 'DD-MON-YYYY HH24:MI:SS') hiredate, 
  2         to_char(today, 'DD-MON-YYYY HH24:MI:SS') today,
  3         FLOOR(seconds/60/60/24) days,
  4         MOD(FLOOR(seconds/60/60), 24) hours, 
  5         MOD(FLOOR(seconds/60), 60) mins,
  6         MOD(seconds, 60) secs
  7  FROM (SELECT SYSDATE hiredate, 
  8               TRUNC(SYSDATE -2) today, 
  9               (SYSDATE-TRUNC(SYSDATE -2)) * 60 * 60 * 24 seconds 
 10        FROM dual);

HIREDATE             TODAY                      DAYS      HOURS       MINS       SECS
-------------------- -------------------- ---------- ---------- ---------- ----------
05-NOV-2010 10:15:57 03-NOV-2010 00:00:00          2         10         15         57

SQL> 
Previous Topic: check box value insertion in table
Next Topic: Disabling lovs when not in enter query mode
Goto Forum:
  


Current Time: Thu Sep 19 17:20:37 CDT 2024