Solved

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

Posted on 2006-07-12
4
733 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 17094729
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
ID: 17094858
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
ID: 17095191
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
ID: 17097757
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans

729 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