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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: date minus one

RE: date minus one

From: Knight, Jon <jknight_at_concordefs.com>
Date: Tue, 29 Mar 2005 14:36:55 -0600
Message-ID: <17ECCBDCF27C544583F2CAD928F953260221FB9A@memex1.corp.cefs.int>


  Thanks for all the suggestions.

  I'm showing my ignorance here, but when using `TZ=GMT+24 date +"%Y%m%d"`, is there any possibility of affecting other sessions connected as the same user? Or worse yet, does changing the TZ affect anything system wide? Hopefully, it's only applicable to that one "date" call or session.

  I can just envision all the Oracle applications suddenly having wild and varied date values.

Thanks,
Jon Knight

 -----Original Message-----

From: 	Thomas Jeff [mailto:jeff.thomas_at_thomson.net] 
Sent:	Tuesday, March 29, 2005 1:34 PM
To:	breitliw_at_centrexcc.com; jknight_at_concordefs.com
Cc:	oracle-l
Subject:	RE: date minus one

That's exactly what I do, e.g:

export YESTERDAY=`TZ=GMT+24 date +"%Y%m%d"`

$ TZ=GMT+24 date +"%Y%m%d"
20050328

-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Wolfgang Breitling Sent: Tuesday, March 29, 2005 2:29 PM
To: jknight_at_concordefs.com
Cc: oracle-l
Subject: Re: date minus one

One trick is to temporarily advance the TZ to a time zone further west, get your date, and then reset TZ again:

$ echo $TZ
MST7MDT
$ date +"%Y-%m-%d"
2005-03-29
$ TZ=MST22MDT
$ date +"%Y-%m-%d"
2005-03-28
$ TZ=MST7MDT
$

Knight, Jon wrote:
> Just curious how the rest of the world gets "yesterday" in UNIX.
> We're running Solaris and we execute a sqlplus script with "select
> sysdate-1 from dual;" and pipe it to tail to set an environment
> variable.
>
> Is there a more UNIXy way, -or- maybe a java function. Any
> suggestions welcome.
>
> TIA,
> Jon Knight
>
> --
> http://www.freelists.org/webpage/oracle-l
>

-- 
Regards

Wolfgang Breitling
Centrex Consulting Corporation
www.centrexcc.com
--
http://www.freelists.org/webpage/oracle-l
--
http://www.freelists.org/webpage/oracle-l
Received on Tue Mar 29 2005 - 15:46:26 CST

Original text of this message

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