The Mighty Blog

Regular Expression - Date

Apr 9

Written by:
4/9/2007  RssIcon

I have another one for you! This one will validate a date within the current century. This should be sufficient enough for most current applications.

^([0-1]?[0-9]{1}/[0-3]?[0-9]{1}/20[0-9]{2})$

The preceding regular expression will, like the previous posting on time, validate most date options. The weaknesses with this one is that it will allow the days to go up to 39 and does not account for leap year. Also, the months can go up to 19, instead of our commonly accepted 12 month year. :)

I designed this expression to validate dates from the year 2000 to 2099. I do not plan on this same code being in place in 2099, so I hope this is sufficient enough...

Tags:
Categories: ASP.Net

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
Add to Technorati Favorites
Tweet about my blog
The opinions expressed here are the personal opinions of Will Strohl and do not necessarily represent the views and opinions of the DotNetNuke Corporation.
© Copyright 2004-2011 by Will Strohl. All rights reserved. Website Skinned By: Ralph Williams  Website Hosted By: Applied Innovations