Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: date minus one
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-lReceived on Tue Mar 29 2005 - 15:46:26 CST