The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Any simple method to check date format (YYDDD)? ganapati UNIX for Dummies Questions & Answers 4 01-03-2008 06:00 AM
Correct format in a log file sd12 UNIX for Advanced & Expert Users 11 12-12-2007 02:40 PM
Check the format of Date AAA Shell Programming and Scripting 2 11-28-2007 01:06 AM
Alternative of format date in HP unix epall UNIX for Dummies Questions & Answers 2 09-29-2007 10:56 PM
Unix Date Format sfpoet UNIX for Dummies Questions & Answers 2 01-17-2002 08:35 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-13-2006
Registered User
 

Join Date: Dec 2004
Posts: 12
Stumble this Post!
Check for the correct date format in UNIx

Hi All,
I am getting two input from User for Date from the command prompt when
my script is executed .
The date format i am taking is : DD-MM-YYYY
so is there any method in Unix to validate the two input date.
There might be many cases for these two date to be invalid. Few are :
Date1 is Greater than Date2.
The format of date1 and Date2 is not correct.
The DD can be more than 31.
Similarly for month.

Thanks
rawat
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-13-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,323
Stumble this Post!
Have you written a script before? If not, then you can start with this. There is no direct way you can do this verification with a single command. You will have to split up the YYYY, MM and DD and then check if they satisfy your requirements. You will have to do this for both the dates.
Then you can compare the dates to check for that date1 greater than date2 error. Use the split up forms of the two dates for this as well. Check for the year first, then the month and then the day.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0