Bhavesh Vankar

Bhavesh Vankar

  • 728
  • 1.1k
  • 77.4k

How to calculate age using DOB

Jul 6 2021 10:29 AM
SqlConnection con = new SqlConnection(this.con);
SqlCommand cmd = new SqlCommand("Select DATEDIFF(YEAR,CONVERT(datetime,'"+ txtDob.Text +"',103),CONVERT(datetime,V_ISSUEDATE,103)) FROM MASTER_NEW", con);
SqlDataReader reader = cmd.ExecuteReader();

how to calculate age using DOB.

When user enter DOB in format dd/MM/yyyy in textbox1 than the age should be display in textbox2 using code behind.

i have tryed to do this with using sql query to take server date as current date.

 but what to do next no getting idea...


Answers (8)