# Compare dates of birth from last and this century

Why is the bot lying to me ?
How can I compare date of births (DOB) from this and the last century?
Could anyone help me: What am I doing wrong? (What’s needed?)

CompareDateOfBirth.zip (32.9 KB)

Hi @bjorn2390,

You can subtract the year of the DOB in the string from the current year, and then the biggest number will be the older person. It’d look something like this:

`Int_Person1sAge = CInt(DateTime.Now.ToString"yyyy") - CInt(Person1sDOB)`
`Int_Person2sAge = CInt(DateTime.Now.ToString"yyyy") - CInt(Person2sDOB)`
`Int_Person1sAge < Int_Person2sAge` in If statement

Hello, @william.coulson
Thanks for helping me out.
I’ve tried your solution. Your theory makes sense, but I’m having trouble with the last statement. How will the BOT know if the extracted year (yy) is from this or the last century?
(Also: Do you agree that the marked Person1sDOB should be DateTime-type variable?)

I don’t see why the conversion to age is done in the example above.
If you have 2 DOB’s, and are capable of converting this to an integer, the smallest integer (the lowest date) is the oldest person.
If your DOB is not a date/time format but a string either convert it to a date/time or transscribe it to yyyyMMdd before comparing.

If cInt(Person1sDOB) > cInt(Person2sDOB) => person 2 is oldest.

And comparing date of birth if you do not have the full year is not possible. You need ddMMyyyy format, or accept inaccuracies.

1 Like

Hi @bjorn2390,

As @Jeroen_Van_Loon1 said, you need a ddMMyyyy format to compare the years.

Also comparing just the year would be more simple than getting the person’s age, must’ve had a process I’d developed locked in

Agreed. Without 4 digits (yyyy) one must be able to accept some inaccuracies. In my case there is no alternative, the social security number contains only two digits (yy). Fortunately, in my case this is sufficient.