1
I would suggest to let it be handled by server itself.
Use Time as the datatype of column.
Try this code.
- CREATE TABLE #tempX(data TIME)
- DECLARE @somedate DATETIME = GETDATE();
- INSERT INTO #tempX
- ( data )
- VALUES ( @somedate
- )
- SELECT * FROM #tempX
- DROP TABLE #tempX
1
You can change the date format using C# as well as SQL .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
DateTime dt = DateTime.Now;
string time = dt.ToString("hh:mm:ss tt");
Console.WriteLine(time);
}
}
}
and if you want to get the time from SQL server Then You can use the Date function .
SELECT CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinute .
I think this will help you :).
0
in sql you can use datatype as time
and in front end you can use any time control like datetime picker
0
Yes, you can..Read the reference for more information
0
If you are using SQL 2008 or newer, you can use TIME Datatype to store only time
Reference
https://msdn.microsoft.com/en-us/library/bb677243.aspx