Adding hours and minutes to time [message #494151] |
Fri, 11 February 2011 09:45 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
ahazin
Messages: 39 Registered: August 2010
|
Member |
|
|
Hi guys, I currently have a problem where I have two date fields with time stamps. The only bit i am currently interested in in these fields is the time factor. When i display them in their field they have a format of HH24:MI .
I have a start time and end time as well as a duration and duration type. What I am trying to do is the following: when the user inputs the start time, along with the duration say 1 for example and the duation type of say HRS for example I would like to have the end_datetime default to 1 HR from the current start time. This is the code I use on a when validate item trigger to acheive this:
case :blk.duration_type
when 'HRS' then
:blk.end_datetime := :blk.start_datetime + ((1/24)* :blk.duration);
when 'MINS' then
:blk.end_datetime := :blk.start_datetime + ((1/24/60)* :blk.duration);
However, everytime it triggers the value put into end_datetime is 0:00 is it something to do with the datatypes im using or would anyopne have a solution to this problem? any help would be very much appreciated.
|
|
|
Re: Adding hours and minutes to time [message #494161 is a reply to message #494151] |
Fri, 11 February 2011 11:00 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/102589.gif) |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
SQL> select sysdate,
2 extract(hour from to_timestamp(sysdate)) hrs,
3 extract(minute from to_timestamp(sysdate)) mins
4 from dual;
SYSDATE HRS MINS
------------------- ---------- ----------
11/02/2011 17:59:42 17 59
Regards
Michel
|
|
|