本文介绍了如何在c#中将整数值转换为时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时间在Integer = 59400,如何将其转换为C#到Timeformat结果是

= 22:03:00.0000000





我的C#代码低于代码方式得到total_mins但超时如何获得total_mins





I have i time in Integer = 59400 , how can I convert it in C# to Timeformat result is
= 22:03:00.0000000


My C# Code is below code wise get total_mins but overtime how to get in total_mins


private void LoadOvertimetotal()
    {
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        con.Open();
        string str = "SELECT total_mins  = SUM(( DATEPART(hh, Overtime_HHMM) * 3600 ) +( DATEPART(mi, Overtime_HHMM) * 60 ) + DATEPART(ss, Overtime_HHMM)) FROM   Accounts_DailyAttendance where UserID='" + gvStaffDetails.SelectedRow.Cells[2].Text.ToString().Trim() + "' and datename(month,processdate) ='" + Session["paymonth"] + "' and datepart(yyyy,processdate)='" + Session["payyear"] + "' and Overtime_HHMM<>'00:00:00.0000000'";
        string strtotminutes = "SELECT totalovertime =  CONVERT(TIME, DATEADD(s, total_mins, 0))FROM Accounts_DailyAttendance";
        cmd = new SqlCommand(str, con);
        cmd = new SqlCommand(strtotminutes, con);
        SqlDataReader reader = cmd.ExecuteReader();
        reader.Read();
        lbltotalovertime.Text = reader["totalovertime"].ToString();
        reader.Close();
        con.Close();
    }





谢谢



Thanks

推荐答案


这篇关于如何在c#中将整数值转换为时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:46