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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Format a long value to a date time value

Format a long value to a date time value

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 Posts 3 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.
  • J Offline
    J Offline
    jluis_hdezg
    wrote on last edited by
    #1

    Could anyone explain to me how to format a long value as a date time value?. This is because I am using Btrieve as a data base and the datetime fields are store as long types. Any help is greatly apreciated. Regards, :)

    D L 2 Replies Last reply
    0
    • J jluis_hdezg

      Could anyone explain to me how to format a long value as a date time value?. This is because I am using Btrieve as a data base and the datetime fields are store as long types. Any help is greatly apreciated. Regards, :)

      D Offline
      D Offline
      Dustin Metzgar
      wrote on last edited by
      #2

      Oh, btrieve, I'm sorry. We, unfortunately, also use btrieve here. But our dates are stored as a string. Probably because it's just a date and not a datetime. Do you know if the long represents seconds or milliseconds? There's probably also a starting date like 1/1/1980 or 1/1/1900. If you had this information you could probably have a constant defined for the start date and just use the AddSeconds or AddMilliseconds methods to add the long value.


      Logifusion[^]

      1 Reply Last reply
      0
      • J jluis_hdezg

        Could anyone explain to me how to format a long value as a date time value?. This is because I am using Btrieve as a data base and the datetime fields are store as long types. Any help is greatly apreciated. Regards, :)

        L Offline
        L Offline
        Larantz
        wrote on last edited by
        #3

        If the Ticks for Btrieve equals Ticks for the System.DateTime then you can use this:

        DateTime theTime = new DateTime(_longValue);

        Otherwise you'd have to find out what the startday is for Btrieve and if it counts in milliseconds or nanoseconds etc, then modify the returnvalue to equal the format for System.DateTime before using the above codesnippet. -Larantz-

        for those about to code, we salute you

        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