DateTime Problem
-
Hello I am working on a system for C #. NET Problem The date in the screen 12/01/2010 But when I store the date in the database sqlServer storage is as follows 22.06.1905 What is the problem How can I solve this problem thanks :rose:
Thaer
-
Hello I am working on a system for C #. NET Problem The date in the screen 12/01/2010 But when I store the date in the database sqlServer storage is as follows 22.06.1905 What is the problem How can I solve this problem thanks :rose:
Thaer
Without seeing your code, it is difficult to tell. Best guess is that you are storing the date as a string, the format of which is local to your region and / or culture. SQL databases use an internal format of "YYYY-MM-DD" and are culture invariant. Do not keep your date as a string - store it in a DateTime and pass that to the SQL directly. Convert it to a display string as late as possible, and convert from a string as soon as possible. Not only is it more efficient in terms of space, but you can easitly perform operations such as comparisons, additions, etc. which you cannot with a string.
All those who believe in psycho kinesis, raise my hand.
-
Hello I am working on a system for C #. NET Problem The date in the screen 12/01/2010 But when I store the date in the database sqlServer storage is as follows 22.06.1905 What is the problem How can I solve this problem thanks :rose:
Thaer
Hi, your question isn't particularly clear, however this[^] might be useful. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Happy New Year to all.
We hope 2010 soon brings us automatic PRE tags!
Until then, please insert them manually.
-
Hello I am working on a system for C #. NET Problem The date in the screen 12/01/2010 But when I store the date in the database sqlServer storage is as follows 22.06.1905 What is the problem How can I solve this problem thanks :rose:
Thaer
I'm not exactly sure what you mean. Do you want to store the Date in a specific manner? If that's the case then check if SQL supports your date format. If not make a function that creates the date in the specified format. Or you could create a DateToString() method or the other way around. Any way you could use: dt = DateTime.Parse() and then check the month,year and day. Again I'm not sure what you want.