Even though the users input the date from a datepicker dd it always resets to 01/01/0001 Any idea on how to ficx this?? Thanx
Thanx for replying, I am using the .UtcNow but it is not working either, I even recreated the whole db and tables, the error of datetime2 and datetime is actually a deployment server issue, I am guessing, because if I entered the value in the date textbox to US format it will accept it MM/DD/YYYY but not the European or other format like dd/mm/yyyy Which is wiered, I have spent many an hour trying to solve this problem and contacted support, no help there, thought they might have an idea on how to fix this, no luck. I have even changed the localization in my Java script, NO LUCK. It works only when I manually enter the month first format. But I do need the app to accept the Euro format. ANy idea?
Well I had to subdue to the server's rule and I had to let the users choose the US date format. I am out of ideas.
Date/Time issues are always tricky as there is always some kind of type conversion. You might want to take a look at this link: http://msdn.microsoft.com/en-us/library/ms186724.aspx I'm not sure where you are having the problem as Visual Studio stores date/time differently than SQL Server, and I'm assuming you're using Visual Studio to develop your application.
Yes I am using VS2010 to develope my site, I am using the Danish/Norwegian char sets for both site and database, and the database on ASPdiscount server, yet I still face the problems with datetime no matter which format of it do I use. Ieven recreated a whole new db with the only Date defs in the tables yet the db on your server still automatically converts or rather resets the date 01/01/0001. I will however look at the link you provided and report back my findings. Thanks for your attention.
Well I finally got it to display an acceptable time, but I am still battling with the US format here is a clip from my Razor code and Jscript. @Html.TextBox( "" , String.Format( "{0:yyyy-MM-dd}" , Model.Value ) , new { @class = "textbox" , @style = "width:200px;" } ) } else { @Html.TextBox("", String.Format("{0:yyyy-MM-dd}", DateTime.Now), new { @class = "textbox", @style = "width:200px;" }) } @{ string name = ViewData.TemplateInfo.HtmlFieldPrefix; string id = name.Replace( ".", "_" ); } <script type="text/javascript"> $(document).ready(function () { $("#@id").datepicker ({ dateFormat: 'yy-mm-dd', showStatus: true, showWeeks: true, highlightWeek: true, numberOfMonths: 1, showAnim: "scale", bla bla bla... and a Jscript class easy and simple function for the datepicker too $(document).ready(function () {$('.date').datepicker({dateFormat: "yy-mm-dd"});}); So this code works for the US format. I have tried changing the format to Euro but that did not work, it would still display the US format. G.D.I. I am now having a problem with the Danish alphabets and apostrophies and quotes not showing right... I think I am gonna quit.
God damn it...!!! it is still resetting the Euro date format in the datepicker. I am just gonna use the yyyy-MM-dd format for all.