Re: plsql date generator, sample code?

From: <RTProffitt_at_beckman.com>
Date: Wed, 05 May 1999 16:37:33 GMT
Message-ID: <7gps4c$pou$1_at_nnrp1.dejanews.com>


[Quoted] Dates in Oracle are pretty easy to work with. Sysdate (or Date Field) + 30, +60, etc... is easy to do See sample:

    select sysdate, sysdate-6 from dual;     05-MAY-99 29-APR-99 We had a need to calculate if user was performing an action within 6 minutes (1 tenth of an hour) and disallow it if so. I had to find the "jobstart" time then find the previous "jobstart" time and see if the difference is within 6 minutes. Here is some code:

    [Quoted]
  • Now check times between jobstarts -- ..... cursor c1(cSerial varchar2) is select time_stamp from job_start_log ...etc ...... open c1(serial); fetch c1 into vDate; <-- go to the log and get previous "jobstart" close c1; .....
  • Positive numbers if jobstarted today. if ((Vdate - trunc(sysdate))*24) > 0 then <- this trunc the minutes and seconds. DAYS*24=hours -- today, check some more. --- -- if same hour, check tenths of hour. -- calculate tenths of hours and compare. Can't be same tenth. if (to_char(vDate,'hh24') = to_char(sysdate,'hh24')) then <-- same hour? if (trunc(to_number(to_char(vDate,'mi'))/6) - trunc(to_number(to_char(sysdate,'mi'))/6) ) = 0 then <-- same tenth hour?
  • not allowed - raise_application_error(-20101, '>>May Not Jobstart in the Same Tenth Hour. '|| 'Wait for 6 minutes.<<'); end if; end if; end if;

Robert Proffitt
Beckman/Coulter
RTProffitt_at_beckman.com

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed May 05 1999 - 18:37:33 CEST

Original text of this message