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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nilesh ShahRank #42 · 34.2K reputationPosted May 18, 2017, 3:14 PM EDT
Code AloneRank #488 · 5.1K reputationPosted Jun 14, 2017, 4:39 AM EDT
Manish KumarRank #1,622 · 956 reputationPosted May 17, 2017, 11:41 PM EDT
Robert Raboud46 reputationPosted May 18, 2017, 3:26 PM EDT
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.
Rafnas T PRank #280 · 8.8K reputationPosted May 18, 2017, 1:15 AM EDT
Catcher WongRank #286 · 8.8K reputationPosted May 18, 2017, 7:02 AM EDT
Robert Raboud46 reputationPosted May 18, 2017, 8:42 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted May 18, 2017, 11:22 AM EDT
Karthi KeyanRank #1,926 · 762 reputationPosted May 18, 2017, 7:54 PM EDT
Vijay KumarRank #6,237 · 272 reputationPosted Jun 8, 2017, 11:49 PM EDT