If you want to validate using a regular expression, this will work for
virtually all SQL Server date formats:
(?m)(?i)(?<DateValue>(?:\d{1,4}[-\.-/]\d{1,2}[-\.-/]\d{1,4}|\d{1,2}\s{1,}\w{3,}\s{1,}\d{2,4}|\w{3,}\s{1,}\d{1,2}\s{1,}\d{2,4})(?:\s{1,}\d{1,2}:*\d{1,2}:*\d{1,2}(?:\.*\d*)?\s*(?:A\.?M|P\.?M\.?)?)?)
This includes such format variations as:
2/1/2007
02/01/07
feb 1 2007
1 Feb 2007
2007-02-01
2/1/2007 6:00 PM
2.1.2007
02/01/07 6:00 P.M.
feb 1 2007 18.00.00
1 Feb 2007 18:00:00.666
2007-02-01 06:00:00 PM
2.1.2007 18:00
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
The shortest distance between 2 points is a curve.
Samuel Shulman said:
Hi
What is the simplest way to validate date input (best if I can use the
ASP.NET validation control)
Thank you,
Samuel