Aug 7, 2007 #1 Matsul IS-IT--Management Joined May 6, 2002 Messages 140 Location BE Is there an easy way of checking if a date is in the format YYYYMMDD ? I have a script that takes a date as input and need it to exist with error in the case of an invalid date. eg >check_report 20070788 ERROR invalid date thanks
Is there an easy way of checking if a date is in the format YYYYMMDD ? I have a script that takes a date as input and need it to exist with error in the case of an invalid date. eg >check_report 20070788 ERROR invalid date thanks
Aug 7, 2007 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi Matsul said: >check_report 20070788 ERROR invalid date Click to expand... Well, that "88" at the end of the string looks strange to me too. If you have GNU [tt]date[/tt], that certainly can recognize that format. Maybe others too. Code: [blue]master #[/blue] date -d 20070788 date: invalid date `20070788' [blue]master #[/blue] date -d 20070708 Sun Jul 8 00:00:00 EEDT 2007 Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi Matsul said: >check_report 20070788 ERROR invalid date Click to expand... Well, that "88" at the end of the string looks strange to me too. If you have GNU [tt]date[/tt], that certainly can recognize that format. Maybe others too. Code: [blue]master #[/blue] date -d 20070788 date: invalid date `20070788' [blue]master #[/blue] date -d 20070708 Sun Jul 8 00:00:00 EEDT 2007 Feherke. http://rootshell.be/~feherke/