Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Minutes Since Midnight 2000

Minutes Since Midnight 2000

From: Guang Mei <zlmei_at_hotmail.com>
Date: Fri, 17 Jan 2003 11:50:28 -0800
Message-ID: <F001.00533689.20030117115028@fatcity.com>


Just idea, how about:

SQL> select 24*60*(sysdate - to_date('00-00-00-01-01-2000', 'SS-MI-HH24-DD-MM-YYYY') ) from dual;

24*60*(SYSDATE-TO_DATE('00-00-00-01-01-2000','SS-MI-HH24-DD-MM-YYYY'))


                                                            1602151.58

You can spool this result to a file and then use "cat | awk" to read the number back to your script.

HTH. Guang

>-----Original Message-----
>From: root_at_fatcity.com [mailto:root_at_fatcity.com]On Behalf Of Post, Ethan
>Sent: Friday, January 17, 2003 1:16 PM
>To: Multiple recipients of list ORACLE-L
>Subject: Minutes Since Midnight 2000
>
>
>I have a very clunky way of calculating the # of minutes in shell since
>2000. This allows me to write the value to a variable and then do the math
>later in a script to figure out how long a job ran, an alert has been
>trigger etc...For those of you working in shell you know date math is not
>so
>easy (without GNU date). This is the simplest method I have found, I would
>just like the function below to look a bit cleaner.
>
>function Minutes {
> # Funky function I use to calculate the number of minutes since 2000
> MIN_YEAR=$( date +"%Y" )
> MIN_YEAR=$( expr ${MIN_YEAR} - 2000 )
> MIN_YEAR=$( expr ${MIN_YEAR} \* 525600 )
> MIN_DAYS=$( date +"%j" )
> MIN_DAYS=$( expr "${MIN_DAYS}" - 1 )
> MIN_DAYS=$( expr "${MIN_DAYS}" \* 1440 )
> MIN_HOURS=$( date +"%H" )
> MIN_HOURS=$( expr "${MIN_HOURS}" \* 60 )
> MIN_MINS=$( date +"%M" )
> MIN_TOTAL=$(( ${MIN_YEAR} + ${MIN_DAYS} + ${MIN_HOURS} + ${MIN_MINS} ))
> print ${MIN_TOTAL}
>}
>
>I am sure there is a more elegant way of doing this, anyone care to share
>thier ideas/improvments/solutions?
>
>Thanks,
>Ethan
>
>Perl is not an option Jared ;)
>--
>Please see the official ORACLE-L FAQ: http://www.orafaq.net
>--
>Author: Post, Ethan
> INET: Ethan.Post_at_ps.net
>



Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Guang Mei
  INET: zlmei_at_hotmail.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Fri Jan 17 2003 - 13:50:28 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US