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