在mysql表中获取日期时间值之间的差异
亲爱的朋友们,
i有mysql表并且有日期时间值,在后面的代码中我想减去这些时间来获得差异。
例如: -
私人TimeSpan get_time_diff(日期时间值1,日期时间价值2)
{
尝试
{
TimeSpan diff0 = value1.Subtract(value2);
返回diff0;
}
catch(例外情况)
{
抛出ex;
}
}
当减去那些值时,最后一个值没有任何值然后给出一个例外,这个位置没有行,那怎么能我解决了这个问题。
dear friends,
i have mysql table and that have date time values,in the code behind i want to subtract these time for get diffrence.
Eg:-
private TimeSpan get_time_diff(DateTime value1, DateTime value2)
{
try
{
TimeSpan diff0 = value1.Subtract(value2);
return diff0;
}
catch (Exception ex)
{
throw ex;
}
}
when subract those value last value doesn't have any value then give an exception there is no row in this position,so how can i solve this problm.
嗨...
看到这个,可能对你来说有用的是你计算的年龄给定日期。
Hi...
see this,may its useful to u.it is calculated age from u are given date.
DateTime pdt = DateTime.Now;
DateTime dob = DateTime.ParseExact(TextBox8.Text.ToString(), "yyyy-mm-dd", null);
int age = pdt.Year - dob.Year;
Label5.Text = age.ToString();
谢谢你。
Thank u.