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. Database & SysAdmin
  3. Database
  4. datetime problem

datetime problem

Scheduled Pinned Locked Moved Database
csharpdatabasehelp
7 Posts 5 Posters 1 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.
  • M Offline
    M Offline
    Member 10263519
    wrote on last edited by
    #1

    Hi, am developing application in .net,c#. am saving datetime value as: yyyy-MM-ss HH:mm:ss (24 hour format) after saving in database i observed in database , it's stored in specified format . and here the problem is: when i retrieve data , datetime is coming as 12 hour format. what to do........

    Kornfeld Eliyahu PeterK J G 3 Replies Last reply
    0
    • M Member 10263519

      Hi, am developing application in .net,c#. am saving datetime value as: yyyy-MM-ss HH:mm:ss (24 hour format) after saving in database i observed in database , it's stored in specified format . and here the problem is: when i retrieve data , datetime is coming as 12 hour format. what to do........

      Kornfeld Eliyahu PeterK Offline
      Kornfeld Eliyahu PeterK Offline
      Kornfeld Eliyahu Peter
      wrote on last edited by
      #2

      When you store date/time AS date/time in database you store some binary (like milliseconds since 1st of January 1970). Database do nothing and care less about the representation of that date/time. You have to look into the code to see where the problem (you may have locals with 12 hours). If you store date/time as string - you do a big mistake!!!

      I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

      "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

      M 1 Reply Last reply
      0
      • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

        When you store date/time AS date/time in database you store some binary (like milliseconds since 1st of January 1970). Database do nothing and care less about the representation of that date/time. You have to look into the code to see where the problem (you may have locals with 12 hours). If you store date/time as string - you do a big mistake!!!

        I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

        M Offline
        M Offline
        Member 10263519
        wrote on last edited by
        #3

        it's ok, but how to add milliseconds. actually, in c# am using DateTimePicker control.this will give only (year-month-date hour:minutes:seconds) it doesn't support milliseconds. so , Is there any way to get the data stored in database as it is.(24 hour format)

        Kornfeld Eliyahu PeterK B 2 Replies Last reply
        0
        • M Member 10263519

          it's ok, but how to add milliseconds. actually, in c# am using DateTimePicker control.this will give only (year-month-date hour:minutes:seconds) it doesn't support milliseconds. so , Is there any way to get the data stored in database as it is.(24 hour format)

          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu Peter
          wrote on last edited by
          #4

          You didn't read or didn't understand what I've told - database do not store date/time in any format but binary!!! For proper formatting in your DateTimePicker go to the help of that specific control...

          I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

          "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

          1 Reply Last reply
          0
          • M Member 10263519

            it's ok, but how to add milliseconds. actually, in c# am using DateTimePicker control.this will give only (year-month-date hour:minutes:seconds) it doesn't support milliseconds. so , Is there any way to get the data stored in database as it is.(24 hour format)

            B Offline
            B Offline
            Bernhard Hiller
            wrote on last edited by
            #5

            You store DateTimePicker.Value, not DateTimePicker.Value.ToString() or DateTimePicker.Text. Also make sure that you set the display format of the DateTimePicker to the format you want to see.

            1 Reply Last reply
            0
            • M Member 10263519

              Hi, am developing application in .net,c#. am saving datetime value as: yyyy-MM-ss HH:mm:ss (24 hour format) after saving in database i observed in database , it's stored in specified format . and here the problem is: when i retrieve data , datetime is coming as 12 hour format. what to do........

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              Member 10263519 wrote:

              am saving datetime value as: yyyy-MM-ss HH:mm:ss (24 hour format)

              That statement is FALSE unless you are storing the value in the database as TEXT. Because it is false your conclusions of what happens after that is incorrect.

              1 Reply Last reply
              0
              • M Member 10263519

                Hi, am developing application in .net,c#. am saving datetime value as: yyyy-MM-ss HH:mm:ss (24 hour format) after saving in database i observed in database , it's stored in specified format . and here the problem is: when i retrieve data , datetime is coming as 12 hour format. what to do........

                G Offline
                G Offline
                GuyThiebaut
                wrote on last edited by
                #7

                Databases save datetime values as numbers. There is no datetime format in which the computer system stores a datetime. Once you understand this you can then understand that the format of the datetime data returned to you will be dependent on the collation of your database, when you perform a simple select,or the format you extract the data as. All you need to remember is that the datetime value is saved, within the database, as a number and you will then understand that all formatting issues are resolvable. N.B. for this reason never save a datetime as a string as if you do you will lose precision.

                “That which can be asserted without evidence, can be dismissed without evidence.”

                ― Christopher Hitchens

                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