本文介绍了asp.net中的datediff函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我必须将start_time和end_time的datediff转换为hours.I已将此差异转换为分钟。这将有效,但我必须将其转换为小时。如何做到这一点? 以下我用来将它转换为分钟的代码。i have to convert datediff of start_time and end_time into hours.I have convert this diff into minute.this will work, but i have to convert it into hours.how to do this ?below code that i have used to convert it into minute.SqlCommand cmd0 = new SqlCommand("select *,Datediff(mi,start_date,end_date) as Duration,Datediff(h,start_date,end_date) from project_log where (end_date between ''" + txt_datefrom.Text + "'' and ''" + txt_dateto.Text + "'' or start_date between ''" + txt_datefrom.Text + "'' and ''" + txt_dateto.Text + "'') and " + ddlsearchby.SelectedValue + " LIKE ''" + txt_searchText.Text + "%''", cnn);推荐答案DATEDIFF(HH,start_date, end_date) as HourDateTime a = new DateTime(2008, 01, 02, 06, 30, 00);DateTime b = new DateTime(2008, 01, 03, 06, 30, 00);TimeSpan duration = b - a;double hours = (b-a).TotalHours; ORORint days = (int)Math.Ceiling(diff.TotalDays); 谢谢Thanks 这篇关于asp.net中的datediff函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-16 12:48
查看更多