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
validating data joanneho Shell Programming and Scripting 1 10-08-2006 09:03 AM
validating 10. IP address any way possible nrodolfich Shell Programming and Scripting 1 02-28-2006 11:58 AM
Validating date in sas radhika03 Shell Programming and Scripting 1 09-16-2005 02:33 AM
Validating $1 and $2 before using nhatch Shell Programming and Scripting 6 09-17-2003 10:01 AM
validating input ruffenator High Level Programming 4 04-24-2002 05:30 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2002
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 158
Talking validating dates

This is what I have to check date entries in an interactive script with the end users... I use this to build control cards for a reporting utility supplied by a software vendor.
I also want to check to make sure its a valid day based on the month (ie 30days has sept, april, june and Nov..)... whats the best way to go that deep?
I'm working in digital unix ksh.
thanks!

while :; do
echo "Enter starting invoice date (CCYYMMDD or Quit): \c"
read DATE1
CENT1=`echo $DATE1 | cut -c1,2`
YR1=`echo $DATE1 | cut -c3,4`
MO1=`echo $DATE1 | cut -c5,6`
DD1=`echo $DATE1 | cut -c7,8`

case "$CENT1" in
19 | 20 ) ;;
* ) echo "Invalid Century, please re-enter entire date. \n" ;;
esac
case "$MO1" in
01|02|03|04|05|06|07|08|09|10|11|12 ) ;;
* ) echo "Invalid Month, please re-enter entire date. \n" ;;
esac
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-05-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,356
Take a look at my datecalc routine. You can use the -j option to validate a date.

datecalc -j 2000 2 29
returns a Modified Julian Day Number while
datecalc -j 2002 2 29
returns an error message. In either case the return code is set. The error message goes to stderr while the MJD goes to stdout.

datecalc is here.
Reply With Quote
  #3 (permalink)  
Old 03-05-2002
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 158
Thumbs up

WOW ! Looks great!

I did a search before I did my posting and I thought I searched on "date" but I don't believe that post came up. ???
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:37 PM.


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