when i am saving date in database it save in "yyyy-mm-dd"
code is:
if(model.Date!=null)
{
string date = model.Date;
}
but i want to save it into "dd-mm-yyyy" format
how to do??
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Code AlonePosted Jun 14, 2017, 8:39 AM
Vijay KumarPosted Jun 9, 2017, 3:49 AM
Karthi KeyanPosted May 18, 2017, 11:54 PM
Robert RaboudPosted May 18, 2017, 7:26 PM
So how does SQL Server internally store the dates? It uses 8 bytes to store a datetime value—the first 4 for the date and the second 4 for the time. SQL Server can interpret both sets of 4 bytes as integers. For the date portion, the value SQL Server stores is the number of days before or after a base date of January 1, 1900. Because of this storage protocol, SQL Server assumed the date of January 1, 1900, when I didn't supply the date in my first example. SQL Server internally stored a value of 0. A negative number represents a date earlier than January 1, 1900.
SQL Server stores the second integer for the time as the number of clock ticks after midnight. A second contains 300 ticks, so a tick equals 3.3 milliseconds (ms). You can see the values for days and clock ticks by converting a datetime value to a binary(8) value and using the substring function to extract each set of 4 bytes.
Nilesh ShahPosted May 18, 2017, 7:14 PM
Amit GuptaPosted May 18, 2017, 3:22 PM
Robert RaboudPosted May 18, 2017, 12:42 PM
Catcher WongPosted May 18, 2017, 11:02 AM
Rafnas T PPosted May 18, 2017, 5:15 AM
Manish KumarPosted May 18, 2017, 3:41 AM