Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-12
4
Medium Priority
?
753 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
Six Sigma Control Plans

715 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