How do i get the cropped integer number

I'm trying to calculate the age based on the DOB.

Int32 DOB = 19900427;
Int32 current = 20140111;
Int32 result = current - dob;

Now i just need to display the starting 2 digit of the result in a text box. Could you please help me with this?

Jon Skeet
people
quotationmark

Don't do it that way. Just don't. You can't get a useful age representation by subtracting one value from another - you'll find that the difference between two people who were born a day apart can differ massively based on exactly when those dates are.

For example, consider three people with birth dates of:

A: December 30th 2013 - 20131230
B: December 31st 2013 - 20131231
C: January 1st 2014   - 20140101

That gives a difference between the ages of A and B of 1, but a difference between the ages of B and C of 8870. It's surely not good for you.

Use DateTime to represent dates - or preferably, use LocalDate from my Noda Time library. Then you can determine the difference between the dates however you want - potentially just in a number of days, for example.

people

See more on this question at Stackoverflow