Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-07-2006, 07:27 PM   #1
Registered: Jan 2004
Posts: 35

Rep: Reputation: 15
Check for invalid date

ok im trying to figure out how to determine if a date YYYYMMDD is invalid without checking if YYYY is greater than 0, MM is greater than 0 and less than 12, and DD is greater than 0 and less then 31/30/29/28. Any ideas?
Old 06-07-2006, 08:30 PM   #2
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Which language are you using? Some have builtin function to do that sort of work for you.
Old 06-07-2006, 08:36 PM   #3
Registered: Jan 2004
Posts: 35

Original Poster
Rep: Reputation: 15
/bin/bash is used
Old 06-07-2006, 09:28 PM   #4
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 34
touch -t $DATE  dummy_file
if [ $? -ne 0 ] ; then
  echo "Invalid date"
If you try to use an invalid date touch will return a non-zero value


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 11:17 AM
glibc 2.3.5 "make check" invalid multibyte sequence sundialsvcs Linux - Software 8 09-09-2005 10:56 AM
squirremail says invalid user or invalid password. rnj Fedora 9 10-25-2004 10:56 PM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 03:10 AM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 01:09 PM

All times are GMT -5. The time now is 09:03 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration