The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10:00 AM
Correct format in a log file sd12 UNIX for Advanced & Expert Users 11 12-12-2007 06:40 PM
Check the format of Date AAA Shell Programming and Scripting 2 11-28-2007 05:06 AM
Alternative of format date in HP unix epall UNIX for Dummies Questions & Answers 2 09-30-2007 01:56 AM
Unix Date Format sfpoet UNIX for Dummies Questions & Answers 2 01-17-2002 12:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-13-2006
rawatds rawatds is offline
Registered User
  
 

Join Date: Dec 2004
Posts: 12
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
  #2 (permalink)  
Old 07-13-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0