Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DateTime Problem

DateTime Problem

Scheduled Pinned Locked Moved C#
questiondatabasehelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thaer Hamael
    wrote on last edited by
    #1

    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

    OriginalGriffO L D 3 Replies Last reply
    0
    • T Thaer Hamael

      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

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      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.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • T Thaer Hamael

        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

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        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.


        1 Reply Last reply
        0
        • T Thaer Hamael

          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

          D Offline
          D Offline
          Dan Mos
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups