Solved

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

Posted on 2006-07-12
4
715 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…

828 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