|
-
Jun 19th, 2007, 08:26 PM
#1
Thread Starter
Fanatic Member
[2.0] computing age base on current date..
using c#, how can i get my age base on the current date? my birthdate is 4/11/1972? the result should be 35? kindly help me pls?
-
Jun 19th, 2007, 08:56 PM
#2
Hyperactive Member
Re: [2.0] computing age base on current date..
You want to paste out whatever code you have so someone could fix it?
-
Jun 19th, 2007, 11:28 PM
#3
Thread Starter
Fanatic Member
Re: [2.0] computing age base on current date..
int age;
DateTime bday;
DateTime cdate;
bday = DateTimePicker1.Value;
cdate = DateTimePicker2.Today;
age = cdate - bday;
-
Jun 20th, 2007, 06:53 AM
#4
Re: [2.0] computing age base on current date..
Try something like
Code:
int years = DateTime.Now.Year - BirthDate.Year;
if (DateTime.Now.Month < BirthDate.Month ||
(DateTime.Now.Month == BirthDate.Month &&
DateTime.Now.Day < BirthDate.Day))
years--;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|