WorldofASP.NET : ASP.NET Tutorial, Hosting, and Source Code
You are 1 of 52 users

Product SpotLight Hosting SpotLight

SQL Server 2005 datetime validation

Blogger : DotNetSlackers Latest ASP.NET News in Category SQL
All posts : All posts by DotNetSlackers Latest ASP.NET News in Category SQL
Category : MSSQL
Blogged date : 2008 Apr 23

This expression validates most legal dates for a SQL Server 2005 datetime format. It includes checking for leap years. (Written for a default U.S. install, not sure what results would be on versions for different regions) For double digit dates, 00 is considered to be the year 2000, so leap years will be valid. This will handle dates in the following formats yymmdd yyyymmdd m/d/yy mm/dd/yy m/d/yyyy mm/dd/yyyy m-d-yy mm-dd-yy m-d-yyyy mm-dd-yyyy m.d.yy mm.dd.yy m.d.yyyy mm.dd.yyyy mmmm dd yy mmmm dd yyyy mmmm dd, yy mmmm dd, yyyy mmmm d yy mmmm d yyyy mmmm d, yy mmmm d, yyyy d mmmm yy d mmmm yyyy dd mmmm yy dd mmmm yyyy d-mmmm-yy d-mmmm-yyyy dd-mmmm-yy dd-mmmm-yyyy d.mmmm.yy d.mmmm.yyyy dd.mmmm.yy dd.mmmm.yyyy d/mmmm/yy d/mmmm/yyyy dd/mmmm/yy dd/mmmm/yyyy mmm dd yy mmm dd yyyy mmm dd, yy mmm dd, yyyy mmm d yy mmm d yyyy mmm d, yy mmm d, yyyy dd mmm yy dd mmm yyyy d mmm yy d mmm yyyy ddmmmyy ddmmmyyyy dd-mmm-yy dd-mmm-yyyy d-mmm-yy d-mmm-yyyy dd.mmm.yy dd.mmm.yyyy d.mmm.yy d.mmm.yyyy dd/mmm/yy dd/mmm/yyyy d/mmm/yy d/mmm/yyyy Note: This will also handle mixing and matching of separator characters. for example: '1/1.2000', It would appear that this is valid in SQL Server 2005. This is written to work for ECMA script (include the ignore case parameter i), but should also work in .Net. I have tested this in firefox 2.0 (Blazing Fast) and IE 7.0 and both seem to work just fine. I have not tested it in .Net. It's pretty large and I have not attempted to optimize it. Feel free to optimize it any way you like.

Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.



Read comments or post a reply to : SQL Server 2005 datetime validation
Page 203 of 1589
Next | Last

.NET News Categories








Legend : - Within 3 Days - Within 6 Days - Within 9 Days

Home | Add Resources | Sponsored Listings | Advertise with Us | SiteMap 1 | SiteMap 2 Link To Us | Contact Us
© 2002-2008 Worldofasp.net ASP.NET Directory, Hosting and Tutorials | All rights reserved
Our Partners : ASP.NET Web Hosting | Windows Web Hosting | FREE ASP.NET CMS | Phone Card | PHP Directory | Bangkok Hotels |Calling Card