How do you get the current time of day?

后端 未结 20 2625
长发绾君心
长发绾君心 2020-11-28 18:40

How do you get the current time (not date AND time)?

Example: 5:42:12 PM

20条回答
  •  一个人的身影
    2020-11-28 19:21

    Try this one. Its working for me in 3tier Architecture Web Application.

    "'" + DateTime.Now.ToString() + "'"
    

    Please remember the Single Quotes in the insert Query.

    For example:

    string Command = @"Insert Into CONFIG_USERS(smallint_empID,smallint_userID,str_username,str_pwd,str_secquestion,str_secanswer,tinyint_roleID,str_phone,str_email,Dt_createdOn,Dt_modifiedOn) values ("
     + u.Employees + ","
     + u.UserID + ",'"
     + u.Username + "','"
     + u.GetPassword() + "','"
     + u.SecQ + "','"
     + u.SecA + "',"
     + u.RoleID + ",'"
     + u.Phone + "','"
     + u.Email + "','"
     + DateTime.Now.ToString() + "','"
     + DateTime.Now.ToString() + "')";
    

    The DateTime insertion at the end of the line.

提交回复
热议问题