View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Convert 2-digit year

You can let VB handle putting in the century for you using this code line...

Range("Bithday").Value = CDate(Mid(IDnumber, 7, 3) & MonthName(Mid( _
IDnumber, 4, 2)) & "-" & Left(IDnumber, 2))

HOWEVER, the point at which VB switches from the 1900s to the 2000s is
determined by the Windows' Regional Settings (which can be changed by the
user). The default breakpoint is 1930... a 2-digit year before 30 will be in
the 2000s (for example, 29 would become 2029 whereas a 2-digit year of 30 or
later would be placed in the 1900 (for example, 30 would become 1930).

--
Rick (MVP - Excel)


"Hennie Neuhoff" wrote in message
...
Hi. All,
Easy one for the experts.
My country use a unique [13 number-digit] Identification system.
The first 6-digits represent the date of birth [yymmdd]
In my code the ID number is entered on a userform as text and
displayed as follows 52-02-08-5034-087 [in this example the d.of b
is 8-Feb-1952]
Range("Bithday").Value = Left(Idnumber, 8)
displays the required birthday in Range("Bithday")
With the note "This cell contains a date string represented with
only 2 digits for the year."
If I select the option "Convert XX to 19XX" it gives me exactly
what I want.
I tried macro record but it doesnt give me any result.
How do I include the "Convert XX to 19XX" in my code ?

--
HJN