.NET DateTime format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LukasMalik
    New Member
    • Jan 2008
    • 22

    .NET DateTime format

    Hi all,

    in my application, I am using DateTime. Until I got in contact with SQL I did not try to solve this problem. Where is set DateTime format?
    Will somehow change application DateTime format if I install my application on diferent computers with diferent localization and different language OS version?
    Current format is dd/mm/yyyy (widely used in Europe). Is format "fixed" with compilation?
    Seconds - my solution has more 'projects' as dll libraries. One is WinForm application UI - do I have possibility to make some solution - general - settings?

    Thanks to all :-)
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    It is always recommended to format the date to a particular format before passing to database for processing. That way there never be any error irrespective of user entry or system date format .

    Comment

    • LukasMalik
      New Member
      • Jan 2008
      • 22

      #3
      Originally posted by debasisdas
      It is always recommended to format the date to a particular format before passing to database for processing. That way there never be any error irrespective of user entry or system date format .
      Of course, but if you change culture from sk-SK to en-US, it will not just change output to database:

      21.3.2008 = myDateTime.ToSh ortDateString()

      to

      3/21/2008 = muDateTime.ToSh ortDateString()

      So, except database errors, it will also affect all input fields where an user types date in sk-SK format but application will throw exception because cannot convert from dd.mm.YYYY to mm/dd/YYYY

      This was main point.

      Thank you :-)

      Comment

      Working...