Hey,
I am struggling to find out the problem with something. Basically on this page:
http://kidsunlimited.co.uk/nursery.aspx?ID=12&Month=April%202010#fragment-11
If you look at the nursery diary tab, will see an article, the first article is named “Test article for archives 1”. Now the date should be 01 April 2010, but instead its showing as 04 Jan 2010.
I don’t understand why. I have been looking at my insert statement and when i insert in the admin section i have a AJax date extender. And it populates the text box like so ‘01/04/2010’
But then when i check in my database i notice it has been added as ‘04/01/2010’.
What does this mean?
My insert statement is like this:
<snip>
The insert works perfectly, but the date format is inserted wrong.
Can someone please help?
Thanks
‘04/01/2010’ doesnt necessarily mean 4th of Jan, it also means April 1st for US date time. But to know exactly what value is stored in ur database, you can run a simple query and cast the date as nvarchar to show you exactly what date it is.
select cast(date_added as nvarchar) as date_added from tbl_diary_articles
Agreed. The thing you need to know about DateTime types is that they DO NOT have a format. Only once you output them to a string do they become formatted.
Otherwise, you’d build a web service, store a DateTime in the format of your local culture’s default, and anyone else around the world would be screwed. Therefore, a DateTime is stored in the way that .NET understands what the date is. This ensures you can add, subtract, compute durations and perform other operations on DateTimes in a standard and reliable way. Then when you need to render the date as a string for display you can choose the appropriate format.