- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- date minus some number
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
Forums
Discussions
Discussions
Forums
Discussions
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
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
05-02-2001 08:19 AM
05-02-2001 08:19 AM
date minus some number
let say today is 05/02/01
substract = 2
should show me 30 (ie 30th,april)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2001 08:54 AM
05-02-2001 08:54 AM
Re: date minus some number
# echo "0d919818576=Y" | adb
1999 Feb 24 02:09:36
Here 919818576 is the number of seconds since 1970 on Feb 24 1999.
If you want to get the day before, let adb subtract 86400 seconds (=1 day):
# echo "0d919818576-0d86400=Y" |adb
1999 Feb 23 02:09:36
Putting this into a small script that, shouldn't be hard, e.g. to get the number of seconds for in four days is simply:
# echo "4 * 86400" |bc
345600
Probably there is also an easier way to do this.
Carsten
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- HhGttG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2001 09:02 AM
05-02-2001 09:02 AM
Re: date minus some number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2001 09:27 AM
05-02-2001 09:27 AM
Re: date minus some number
to complete what Carsten do:
Put in a file (minus.c)
#include
#include
int main(argc, argv)
int argc;
char *argv[];
{
struct timeval time;
if (argc!=2) {
printf("Error\n");
exit(0);
}
gettimeofday(&time,NULL);
printf("0d%d=Y",time.tv_sec - atoi(argv[1])*86400);
}
Compile it:
#cc minus.c -o minus
And then (if you want to know the date 2 days ago)
#echo `./minus 2`|adb
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2001 02:45 PM
05-02-2001 02:45 PM
Re: date minus some number
The attached script does the job by using 'cal' to quickly determine the number of days in the previous month.
You can probably make it shorter, especially if you do not require a particular date format in the output.
Mladen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2001 02:50 PM
05-02-2001 02:50 PM
Re: date minus some number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2001 05:48 AM
05-03-2001 05:48 AM
Re: date minus some number
perl -e 'print scalar localtime(time-2*86400),"\n"'
If you need fancier formatting check the list entries returned from localtime in an array/list l-value context:
perldoc -f localtime
or
perldoc perlfunc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2001 06:18 AM
05-03-2001 06:18 AM
Re: date minus some number
Hope this helps
regards Davide