Solved

setting date variable to be yesterday's date in Perl AIX

Posted on 2006-07-12
4
703 Views
Last Modified: 2006-11-18
Actually I have sh script which sets the following variable:

TDATE=`date +%Y%m%d`

We then use this variable to set another variable:

CSFILE="test$TDATE"

I need help setting the TDATE variable to be yesterday's date.

This is very important, vendor switched when they send their file and it is always a day behind, example of a file they send would be: test20060706.txt

I am giving 500 points for this answer.
0
Comment
Question by:mhorrocks
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
Is this perl, or an sh script?

If it's an sh script: You might be more answers in the OS->Unix topic area, or maybe OS->Linux.

If it's a perl script, you could use the strftime to format the time
See here for more info:
http://perldoc.perl.org/POSIX.html
0
 

Author Comment

by:mhorrocks
Comment Utility
Ok.  I need to delete this question and I will submit it under Unix SH scripting.

please delete this question and return the points.
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
To delete the question you need to post a question in community support ("Help" link at top-right of page)
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
in Perl:
$TDATE=strftime"%Y%m%d", localtime time-24*60*60; #this may not be quite right for an hour near midnight when there is a daylight savings switchover

in unix sh, if your date command supports it:
TDATE= `date --date yesterday "+%Y%m%d"`
or if your version of unix can handle the appropriate  timezone offsets
TDATE=`TZ=+24 date +%y%m%d`
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now