[AccessD] All-In-One Date format Function:

Heenan, Lambert Lambert.Heenan at chartisinsurance.com
Wed Oct 21 13:48:33 CDT 2009


Robert,

If you would like to remain sane they I suggest you step away from the problem. "I would like the user to enter it the way they want to" is just not a good idea. What if your company hires a Brit who wants to enter 10/1/09 - meaning January 10th 2009? Or a Japanese who enters 10/01/09 but means January 9th 2010?

To me, the simplest solution to managing date input is to not permit freeform entry, but rather to pop up a small calendar form any time a Date field is clicked on.

As for a routine to convert existing freeform dates? I don't think you can beat Cdate([YourData])

Cdate can handle just about anything that looks like a date and if it's unambiguous will give you a real date back. It will of course assume mm/dd/yyyy when the input data is not clear. Just another reason NOT to allow freeform date entry. Feed it really weird input like 92109 and you will get back 3/7/2152, because that date is 92,109 days after 12/30/1899 - the basis of Access dates.

Doing any better than this is going to require various assumptions to be coded regarding what comes first a month a day or a year. Why have the problem to deal with? Use a calendar form.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Robert
Sent: Wednesday, October 21, 2009 2:17 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] All-In-One Date format Function:

Hoooooowdy,
 Before re-inventing the wheel here, does anyone have or know of a function that can handle "free form" date formatting. I'm looking for a function that can parse any input and then format is correctly. 

Example of user inputs:

0909
09/21/09
09-21-09
092109
92109
9212009

etc.

I don't want to use any formatting / Masking settings at the field or table level. I would like the user to enter it the way they want to (to the most degree possible)...

WBR
Robert

  


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list