Does anyone know an elegant method to compute someones birthday from his date-of-birth (given in a TDateTime)?
I'm able to decode the year from a given TDateTime, but I don't see how to set the year.
Do you mean you want to get a TDate containing the date of the person's next
birthday?
You could use TDateTime:ecodeDate to break the date-of-birth down into year/month/day, get the current year also using DecodeDate, combine that with the person's month/day, then use TDateTime::EncodeDate to get a TDate. If that is less than the current date, add 1 to the year, and EncodeDate again.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.