' Convert two digits to year ' A number from 0 to 99 that specifies the year equal to and above which is the current century and below which is the next century. ' The default value for nYear is the last two digits of the current year plus 50 years - if the current year is 1998, nYear is 48, ' the last two digits of 2048 (1998 + 50). ' Note that the rollover value only determines the century for a date entered without a century portion - an ambiguous date format ' that is not recommended. ' For example, if the current year is 1998 and nYear is the default (48), any date entered without a century portion and a year of ' 48 or greater is considered to be in the current century (the 20th century). Any date entered without a century portion but with a ' year before 48 is considered to be in the next century (the 21st century). ' expC1 Two digits ' expN1 Rollover year ' expN2 Century Public Function ConvertTwoDigitToYear(ByVal tcTwoDigit As String, ByVal tnRollover As Integer, _ ByVal tnCentury As Integer) As Integer Dim lcTwoDigit As String = "" Dim lcYear As String = "" Dim ldDate As Date = Nothing Dim lnCentury As Integer = 0 Dim lnRollover As Integer = 0 Dim lnTwoDigit As Integer = 0 Dim lnYear As Integer = 0 ' Initialization lcTwoDigit = tcTwoDigit ldDate = Date.Now lnCentury = 21 lnRollover = Val(Mid((ldDate.Year + 50).ToString, 3, 4)) ' If we have a rollover value If tnRollover > 0 Then lnRollover = tnRollover End If ' If we have a century value If tnCentury > 0 Then lnCentury = tnCentury End If ' If this is numeric If oApp.IsNumeric(lcTwoDigit) Then ' If we have one or two digits If lcTwoDigit.Length = 1 Or lcTwoDigit.Length = 2 Then ' Get it into a numeric lnTwoDigit = Val(lcTwoDigit) ' A century is always ahead lnCentury = lnCentury - 1 ' If we are not in this century If lnTwoDigit >= lnRollover Then lnCentury = lnCentury - 1 End If ' Get the year in character lcYear = lnCentury.ToString + lcTwoDigit.PadLeft(2, "0") ' Get the year in numeric lnYear = Val(lcYear) Else ' If we have four digits If lcTwoDigit.Length = 4 Then ' If we have four digits lnYear = Val(lcTwoDigit) End If End If End If Return lnYear End Function