[AccessD] Tip: Birthday of current year

Gustav Brock Gustav at cactus.dk
Sun Apr 27 16:12:42 CDT 2008


Hi all

Not a big problem except for the detail with date of birth of Feb. 29th. 
But DateAdd will sort that out. The trick here is that year 2000 is a leap year.

Here's a method in SQL:

  SELECT 
    *,
    DateAdd("yyyy",Year(Date())-2000,DateSerial(2000,Month([DOB]),Day([DOB]))) AS BirthdayThisYear
  FROM 
    tblTest;

And as VBA:

  datBirthdayThisYear = _
    DateAdd("yyyy", Year(Date) - 2000, DateSerial(2000, Month(datDOB), Day(datDOB)))

/gustav








More information about the AccessD mailing list