|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Date comparison
Date comparison
Hello all I am writing a scrip that will take action so long as the date with in the file is older than 3 months. The file will contain multiple rows of data. Each row will probably start with the date. My question... What is the exact code that should be used for date comparison. I am thinking if date A > current date Then do task... else fi will Date A > current date surfice? Last edited by UofU; 01-19-2011 at 01:13 PM.. Reason: typo |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
Well, YYYY-MM-DD HH:MM:SS date-time compares right as strings, so generally the quickest way to compare is to shuffle the bytes around to that format.
To generate the date 3 months ago in that format, you need date arithmetic, usually the realm of C/C++/JAVA/PERL/etc., with leap year knowledge for month lengths and such. Some of the later shells, like ksh93 and certainly bash, have date arithmetic. Is this 3 months = 90 days or varying? |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Date comparison using ksh | informix2009 | Shell Programming and Scripting | 4 | 01-04-2010 05:53 PM |
| Date comparison with 'string date having slashes and time zone' in Bash only | TariqYousaf | Homework & Coursework Questions | 1 | 10-08-2009 01:27 PM |
| date comparison in bash | carp.dk | Shell Programming and Scripting | 6 | 07-17-2009 09:44 AM |
| Date comparison | sumesh.abraham | Shell Programming and Scripting | 6 | 12-14-2006 12:28 AM |
| date comparison | dkr123 | Shell Programming and Scripting | 2 | 07-07-2006 09:09 PM |
|
|