Solved

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

Posted on 2006-07-12
4
722 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl split by | 2 111
collecting information 2 205
problem with using the glob function 1 77
use google analytics code in perl script 2 92
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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 …
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…

730 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