TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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
Reply
Answers (
2
)
Reporting Tools
How to use mongoDB with Asp.Net MVC ?