|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Previous Date In LInux
Hi Guys
I am working on Solaris 9.0. How can I subtract system date by 1,2,3 days and stored into an variable Help Me pls Regards Amit Midha (Oracle DBA) |
|
#2
|
|||
|
|||
|
Here is a pointer to an article on the subject:
http://www.samag.com/documents/s=8284/sam0307b/0307b.htm |
|
#3
|
|||
|
|||
|
I had the same problem and I have solved it by simple C program delta_days:
You can call it this way: delta_days -1 %D Format specification: see man page man strftime /************************************************************************/ /* Program to generate datum that differs from current time */ /* of a given number of days */ /* Call: delta_d number_of_days format */ /* format - see man strftime */ /* delta_d < 0 : shift into the past */ /* delta_d = 0 : current time and datum */ /* delta_d > 0 : shift into the future */ /************************************************************************/ #include <stdio.h> #include <sys/types.h> #include <time.h> #define BUFL 1000 int main (int argc, char *argv[]) { time_t t; /* Time in seconds of era */ unsigned long d; /* total number of days */ char * endc; /* ending character of argv[1] */ struct tm * loct; /* the time structure */ char buf[BUFL]; /* working space */ if (argc != 3) { fprintf (stderr, "%s: call: %s count_of_days format\n", argv[0], argv[0]); exit (1); } d = strtol (argv[1], &endc, (int)10); if (*endc != 0) { fprintf (stderr, "%s: count_of_days must be an integer\n", argv[0]); exit (1); } t = time (NULL) + d*24*60*60; loct = localtime (&t); strftime (buf, (size_t) BUFL, argv[2], loct); printf ("%s\n", buf); } Regards |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Previous Date In LInux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|