[HPADM] Re: yesterday date manipulations

From: Vic (vicryan@pop500.gsfc.nasa.gov)
Date: Wed Dec 29 2004 - 09:21:56 EST


Morning,

The following perl command will give you any date, past or future.
Just change the time - or + value to the number of days to offset.
___m1= minus 1, ___p1=plus 1

# Set to Yesterday
set -- $(perl -e 'print scalar localtime (time -1 * 86400),"\n"' | \
        awk '{print $1" "$2" "$3" "$4" "$5}'); \
        datem1="$*" daym1="$1" monthm1="$2" domm1="$3" \
        timem1="$4" yearm1="$5"

# here domm1 will equal yesterday's date.....
# Works for year changeover also

# Set to today
set -- $(perl -e 'print scalar localtime' | \
       awk '{print $1" "$2" "$3" "$4" "$5}');\
       today="$*" day="$1" month="$2" dom="$3" time="$4" year="$5"
# All Tue Dec 28 08:55:53 2004

# Set to tomorrow
set -- $(perl -e 'print scalar localtime (time +1 * 86400),"\n"' | \
        awk '{print $1" "$2" "$3" "$4" "$5}'); \
        datep1="$*" dayp1="$1" monthp1="$2" domp1="$3" \
        timep1="$4" yearp1="$5"

This works great, I use it to get a command line listing of my
Data Protector schedule 14 days in advance.

My thanks to whomever posted it to the net some time ago in some
other forum.

Vic

-- 
James V. Ryan
Bldg. 23, Code 585
Goddard Space Flight Center
Greenbelt, MD  20771, USA
301-286-8869
On 12/29/04 8:00 AM, "HAUTECOEUR Bruno" <HAUTECOB@ESSILOR.fr> wrote:
> 
> Hi admins
> 
> in order to get the "yesterday" date, i use the following syntax:
> 
> `TZ=MET-1METDST+24 date +%d%m%Y`
> 
> This works fine for days from 2 to 30 or 31. But it doesn't work for the 1st
> of the month. 
> 
> Do to know the way to make this work also for the 1st day ?
> 
> Regards
> 
> ________________
> Bruno HAUTECOEUR
> Architecte système Unix
> DSI / Architecture & Systèmes - Essilor International
> Tel: 33 (0)1 72 94 73 20 - Fax: 01 39 26 53 08
> mail: hautecob@essilor.fr
> 
> 
--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:45 EDT