Re: date minus one

  • From: Wolfgang Breitling <breitliw@xxxxxxxxxxxxx>
  • To: jknight@xxxxxxxxxxxxxx
  • Date: Tue, 29 Mar 2005 12:29:29 -0700

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
> 
> --
> //www.freelists.org/webpage/oracle-l
> 

-- 
Regards

Wolfgang Breitling
Centrex Consulting Corporation
www.centrexcc.com
--
//www.freelists.org/webpage/oracle-l

Other related posts: