- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How do I subtract 1 day from date
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2001 10:22 AM
08-28-2001 10:22 AM
How do I subtract 1 day from date
Day = 'date +%a'
dumpfile="holdfile_${Day}.dmp.Z
I need to subract 1 day from the date.
Can you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2001 10:32 AM
08-28-2001 10:32 AM
Re: How do I subtract 1 day from date
You could do something as simple as
YESTERDAY=`TZ=PST+24 date +%D`
or in perl
yesterday=$(perl -e 'print scalar localtime(time-1*86400),"\n"' | cut -c 5-11)
If you want more, just do a search in the forums, you will get quite a few options
-Regards
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2001 10:38 AM
08-28-2001 10:38 AM
Re: How do I subtract 1 day from date
My mistake, you are using
Day = `date +%a`
which gives the day of the week, so you may have to use
yest=`TZ=PST+24 date +%a`
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2001 10:39 AM
08-28-2001 10:39 AM
Re: How do I subtract 1 day from date
DAY=`date +%j`
YESTERDAY=`expr $DAY - 1`
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2001 10:56 AM
08-28-2001 10:56 AM
Re: How do I subtract 1 day from date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2001 11:29 AM
08-28-2001 11:29 AM
Re: How do I subtract 1 day from date
DAY=`date +%u` #DAYS of week mon-sun 1-7
if [ $DAY -eq 1 ]
then
YESTERDAY=7
else
YESTERDAY=`expr $DAY - 1`
fi
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 02:43 PM
08-31-2001 02:43 PM
Re: How do I subtract 1 day from date
perl -e 'print scalar localtime(time-1*86400),"\n"'
And yes this works with text dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 03:22 PM
08-31-2001 03:22 PM
Re: How do I subtract 1 day from date
I will prepare a table like this
MON=1
TUES=2
WED=3
THU=4
FRI=5
SAT=6
SUN=7
NOW you can use the same trick as told by Joseph.
DAY=`date +%u`
if [ $DAY -eq 1 ]
then
YESTERDAY=7
else
YESTERDAY=`expr $DAY - 1`
YESTERDAY_IS=`grep YESTERDAY table |awk '{FS=
"=";print $1}`
fi
You can use YESTERDAY_IS in your program to replace the day of the week.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 03:22 PM
08-31-2001 03:22 PM
Re: How do I subtract 1 day from date
I will prepare a table like this
MON=1
TUES=2
WED=3
THU=4
FRI=5
SAT=6
SUN=7
NOW you can use the same trick as told by Joseph.
DAY=`date +%u`
if [ $DAY -eq 1 ]
then
YESTERDAY=7
else
YESTERDAY=`expr $DAY - 1`
YESTERDAY_IS=`grep $YESTERDAY table |awk '{FS=
"=";print $1}`
fi
You can use YESTERDAY_IS in your program to replace the day of the week.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 11:37 PM
08-31-2001 11:37 PM
Re: How do I subtract 1 day from date
Here is a nice script written by Tom Danzig that will work back to 01/01/01.
usage is :- datwhen -n
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 11:38 PM
08-31-2001 11:38 PM
Re: How do I subtract 1 day from date
to clarify the datewhen bit :- that is what I called the script on my server.
Paula