- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Date manipulation
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
тАО04-20-2009 12:34 AM
тАО04-20-2009 12:34 AM
Say on 1st April, I have to check the logs of yesterday which is 31st March. Then how would my system will act according to the month whatever comes.
what would be the solution?
Solved! Go to Solution.
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2009 12:39 AM
тАО04-20-2009 12:39 AM
Solutionhttp://www.cmve.net/merijn/caljd-2.25.sh
resolves most of these date manipulation challenges...
HTH
Duncan
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2009 12:46 AM
тАО04-20-2009 12:46 AM
Re: Date manipulation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2009 12:50 AM
тАО04-20-2009 12:50 AM
Re: Date manipulation
Read the script.
There is commentary inside that says exactly how to use it.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2009 04:18 AM
тАО04-20-2009 04:18 AM
Re: Date manipulation
If it's simply yesterday that you want to derive (in whatever format you desire), use a simple Perl script:
# perl -MPOSIX -le 'print strftime("%b %02d",localtime(time-24*60*60))'
Apr 19
You can use any of the 'date' formatting directives in place of what I have shown.
For example if you wanted a MM/DD/YYYY format:
# perl -MPOSIX -le 'print strftime("%m/%02d/%Y",localtime(time-24*60*60))'
04/19/2009
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2009 10:50 PM
тАО04-20-2009 10:50 PM
Re: Date manipulation
Suppose I want to show the yesterday or day before yesterday date, and my current date is the first of month. How can I manipulate that the previous date was the last of past month?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2009 11:47 PM
тАО04-20-2009 11:47 PM
Re: Date manipulation
do you need the last day of teh previous month or yesterday?
Please, specify.
Rgds,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2009 01:15 AM
тАО04-21-2009 01:15 AM
Re: Date manipulation
> Suppose I want to show the yesterday or day before yesterday date, and my current date is the first of month.
The Perl snippet I offered handles month and/or year changes too. With a minor modification, we can make the code report any number of days in the past or the future. Once again, you can use any of the 'date(1)' or 'strftime(3C)' formatting directives you see in their manpages.
# perl -MPOSIX -le '$d=shift||1;print strftime("%b %02d",localtime(time-$d*24*60*60))'
...yields yesterday as we have seen. NOtice that I didn't pass any argument. I could have passed "1" for one-day. Passing an argument of "0" would simply return today.
# perl -MPOSIX -le '$d=shift||1;print strftime("%b %02d",localtime(time-$d*24*60*60))' 2
...gives you the date two days ago.
perl -MPOSIX -le '$d=shift||1;print strftime("%b %02d",localtime(time-$d*24*60*60))' -- -1
...gives you tomorrow. NOtice that the '--' says that what follows isn't a switch, but an argument.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2009 09:54 PM
тАО07-03-2009 09:54 PM
Re: Date manipulation
I have a perl script which read date from a file and convert it like "yyyymmdd". But problem is if its read the date like "Fri Jul 13 04:44:01 2009" then its output is "20090713" whether when it reads the date like
"Sat Jul 4 12:54:22 2009" then it doesn't gives any output. The code is like
$ cat filter.pl
#!/usr/bin/perl -nl
BEGIN{
%m=(Jan=>1,Feb=>2,Mar=>3,Apr=>4,May=>5,Jun=>6,
Jul=>7,Aug=>8,Sep=>9,Oct=>10,Nov=>11,Dec=>12)};
m{^Event.+(\w{3})\s(\d\d|\d).+\s(\d{4})} and
printf "%4d%02d%02d\n",$3,$m{$1},$2;
1;
how can i solve this?