[AccessD] Date Format

Stuart McLachlan stuart at lexacorp.com.pg
Sat Feb 1 16:18:00 CST 2003


> I am having a problem formatting a Date of Birth when
> the data uses the "mm/dd/yy" format
> 
> I want to use the following code
> 
> Format([PatDob],"yyyymmdd")
> 
> to format the data in the form required for another
> application and everything works fine except when I
> encounter someone born before 1930. My code turns
> 11/01/29 into 20291101
> but it turns
> 11/02/30 into 19301102 like I want.
> 

It's specific to the computer. Regional Settings - Date is used to define the "epoch" ie 
how to interpret 2 digit dates.  The default in 1930-2029.  

When the data is saved in a table, it may display as a two digit year, but the actual value 
in the table is the appropriate four digit year according to the epoch setting when it was 
saved.

Where is the data coming from. If you are talking about keyboard entry do something 
like. 

On_Update()
'Assume dates in the future are meant to be 19XX.
If PatDOB > Date() then PatDOB = DateAdd("yyyy",-100,PatDOB)
'or 
'Assume all dates are 19XX
If year(PatDOB ) > 1999 then PatDOB = DateAdd("yyyy",-100,PatDOB)

-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.






More information about the AccessD mailing list