- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: DATE 'n' Days Ago or After from Current Date
Operating System - HP-UX
1748222
Members
4445
Online
108759
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2008 03:33 AM
тАО09-14-2008 03:33 AM
Hi All,
I want to write a script to get a date 3 days (calender days) ago from current date or after from current date.
The easiest method could be to use %j in date cmd and get the day of the year (current year) in decimal format and minus (or add ) number of days "n" for which you want the date.
Now after getting this number how to get the date of thay day of the year is my problem?
I would really appreciate if someonoe can suggest other way of getting the end result?
I want to write a script to get a date 3 days (calender days) ago from current date or after from current date.
The easiest method could be to use %j in date cmd and get the day of the year (current year) in decimal format and minus (or add ) number of days "n" for which you want the date.
Now after getting this number how to get the date of thay day of the year is my problem?
I would really appreciate if someonoe can suggest other way of getting the end result?
Solved! Go to Solution.
- Tags:
- date arithmetic
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2008 03:59 AM
тАО09-14-2008 03:59 AM
Solution
Hi:
Use Perl;
# perl -MPOSIX -le 'print strftime "%Y-%m-%d",localtime(time-(3*60*60*24))'
2008-09-11
perl -MPOSIX -le 'print strftime "%Y-%m-%d",localtime(time+(3*60*60*24))'
2008-09-17
You can use the same formatting directives you use with the Unix 'date' command by using 'strftime':
# perl -MPOSIX -le 'print strftime "%b %d",localtime(time-(3*60*60*24))'
Sep 11
Regards!
...JRF...
Use Perl;
# perl -MPOSIX -le 'print strftime "%Y-%m-%d",localtime(time-(3*60*60*24))'
2008-09-11
perl -MPOSIX -le 'print strftime "%Y-%m-%d",localtime(time+(3*60*60*24))'
2008-09-17
You can use the same formatting directives you use with the Unix 'date' command by using 'strftime':
# perl -MPOSIX -le 'print strftime "%b %d",localtime(time-(3*60*60*24))'
Sep 11
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2008 04:17 AM
тАО09-14-2008 04:17 AM
Re: DATE 'n' Days Ago or After from Current Date
Thanx you Very much.
Great..
Great..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2008 04:17 AM
тАО09-14-2008 04:17 AM
Re: DATE 'n' Days Ago or After from Current Date
.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP