aditya immadi

aditya immadi

  • NA
  • 215
  • 23.6k

calculating age from date picker

Oct 3 2016 1:24 AM
hai i m trying to calcuating age from mvc annotaions date picker 
datatypes of DOB is datetime and age is in int .when i m trying to wrote like this i found a error like input sting is not in correct formate
 
my code is
public ActionResult AddTrainer(Tbl_Trainer _obj, HttpPostedFileBase file)
{
var thisyear = DateTime.Now.Year;
var birthyear = _obj.Dateofbirth;
// int age = (Int32.Parse(thisyear) - Int32.Parse(birthyear.ToString())) / 10000;
int age = (int)thisyear - int.Parse(_obj.Dateofbirth.Value.ToString())/1000;--input sting is not in correct formate
int outletid=(int) Session["id"];
if (file != null && file.ContentLength > 0)
{
BinaryReader br = new BinaryReader(file.InputStream);
var filename = Path.GetFileName(file.FileName);
int filelength = filename.Length;
byte[] filedata = br.ReadBytes((int)file.InputStream.Length);
int i = _Dalobj.AddTrainer(outletid,_obj, filedata, age);
if (i == 1)
 
{....
...}
 
TIA 
 

Answers (2)