Home » Developer & Programmer » Forms » calculate the time
calculate the time [message #338795] Tue, 05 August 2008 23:35 Go to next message
sajidrazmi
Messages: 47
Registered: August 2008
Location: oman
Member
Dear All I am getting a problem in forms
if i have a vlue 298 how to i convert in hours and minute just like this
298 = 5:58 hrs

i am doing in form 6i

or
one problem is i have one column in_time (value 08:00 AM) and second column out_time (value 01:10 PM) i have to calculate how much hours in between .

so please help me out of this problem
thanks in advance


[Updated on: Tue, 05 August 2008 23:35]

Report message to a moderator

Re: calculate the time [message #338809 is a reply to message #338795] Wed, 06 August 2008 00:20 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If you can describe how 298 minutes = 5 hours 58 minutes, I'd be interested in reading.

If "time" values you are talking about are stored into the DATE columns (but you have chosen to display time only), subtracting two DATE columns is number of days between these two dates.

Now it is only matter of your calculation skills to present this value in a desired format (a day has 24 hours, an hour has 60 minutes, ...).
Re: calculate the time [message #338822 is a reply to message #338809] Wed, 06 August 2008 01:02 Go to previous messageGo to next message
sajidrazmi
Messages: 47
Registered: August 2008
Location: oman
Member
HI
i have two colums in a block tas_temp_post_lunch_in, and second one is tas_temp_evening_out in this column in value is 08:00 AM
and out_value is 12:58 PM i have to calculate in between the hours i have written code for this
if i write this code the value come 4.81 but excat value is 4.58
:blk_tas_temp.tas_temp_tot_evening:=(to_date(:blk_tas_temp.tas_temp_evening_out,'HH:MI AM')-to_date(:blk_tas_temp.tas_temp_post_lunch_in,'HH:MI AM'))*24 ;

and if i write this
:blk_tas_temp.tas_temp_tot_evening:=(to_date(:blk_tas_temp.tas_temp_evening_out,'HH:MI AM')-to_date(:blk_tas_temp.tas_temp_post_lunch_in,'HH:MI AM'))*24*60 ;
then value come 298

i need 4.58 value
how it come please tell or write code
thanks

[Updated on: Wed, 06 August 2008 01:04]

Report message to a moderator

Re: calculate the time [message #338835 is a reply to message #338822] Wed, 06 August 2008 01:37 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As I've said, it is matter of calculation. Here's an example; you might search for a better solution, figure out your own, or do whatever you like:
SQL> select &&minutes, &&minutes / 60 divide,
  2    trunc(&&minutes / 60) hours,
  3    (&&minutes / 60 - trunc(&&minutes / 60)) * 60 min
  4  from dual;
Enter value for minutes: 298

       298     DIVIDE      HOURS        MIN
---------- ---------- ---------- ----------
       298 4.96666667          4         58

SQL>
Re: calculate the time [message #338840 is a reply to message #338795] Wed, 06 August 2008 01:47 Go to previous messageGo to next message
gurupatham
Messages: 66
Registered: March 2008
Location: Chennai
Member
Extract hour and second separately like below

nhour:=trunc((to_date(:blk_tas_temp.tas_temp_evening_out,'HH:MI AM')-to_date(:blk_tas_temp.tas_temp_post_lunch_in,'HH:MI AM'))*24) ;


nSec:=(to_date(to_char(to_date(:blk_tas_temp.tas_temp_evening_out,'HH:MI AM') , 'MI') , 'MI')
-to_date(to_char(to_date(:blk_tas_temp.tas_temp_post_lunch_in,'HH:MI AM') , 'MI' ) , 'MI'))*24*60 ;
Re: calculate the time [message #338884 is a reply to message #338795] Wed, 06 August 2008 03:17 Go to previous messageGo to next message
sajidrazmi
Messages: 47
Registered: August 2008
Location: oman
Member
hi dear if i am doing this it giving me seperate result
how i could assign in one column because
it is giving in hrs 4:00
how i have to add

and minutes 1:00
total is 4:01

please tell me
thanks
Re: calculate the time [message #338893 is a reply to message #338795] Wed, 06 August 2008 03:51 Go to previous messageGo to next message
gurupatham
Messages: 66
Registered: March 2008
Location: Chennai
Member
Just concatenate both hours and minute and convert to date .
ex:
to_date(nHour||':'||nSec , 'HH:MI PM')

Re: calculate the time [message #338995 is a reply to message #338893] Wed, 06 August 2008 07:16 Go to previous messageGo to next message
sajidrazmi
Messages: 47
Registered: August 2008
Location: oman
Member
HI
DEAR WHEN I AM DOING THIS ERROR IS COMING STATEMENT IGNORED.
TEMPH:=trunc((to_date(:blk_tas_temp.tas_temp_evening_out,'HH:MI AM')-to_date(:blk_tas_temp.tas_temp_post_lunch_in,'HH:MI AM'))*24) ;

TEMPS:=(to_date(to_char(to_date(:blk_tas_temp.tas_temp_evening_out,'HH:MI AM') , 'MI') , 'MI')
-to_date(to_char(to_date(:blk_tas_temp.tas_temp_post_lunch_in,'HH:MI AM') , 'MI' ) , 'MI'))*24*60 ;
:BLK_TAS_TEMP.TAS_TEMP_TOT_EVENING := TO_DATE(TEMPH||':'|| TEMPS,'HH:MI PM');
Re: calculate the time [message #339165 is a reply to message #338795] Wed, 06 August 2008 23:41 Go to previous message
gurupatham
Messages: 66
Registered: March 2008
Location: Chennai
Member
Check whether database connected or not?
Previous Topic: Tns Protocol Adapator Error Data base not Loaded in oracle 8.1.5
Next Topic: WEB.SHOW_DOCUMENT
Goto Forum:
  


Current Time: Mon Feb 10 00:37:09 CST 2025