CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: DateTime weird

  1. #1
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    440

    Question DateTime weird

    Trying to estimate when a test will end
    Code:
    DateTime EndTime = new DateTime(DateTime.Now.Ticks + NTests * 20000000);
    This gives me an end time lower than DateTime.Now !?!? Thought it was caused by long overflow, but no result is lower than 9,223,372,036,854,775,807. Any idea what might be wrong here ?

  2. #2

    Re: DateTime weird

    Why will you need Ticks? Its nanoseconds from 1970. Why will you add to that? You can simply take the current time and if you know Ntests and how much time each test takes, then that can be added to current time.

  3. #3

    Re: DateTime weird

    Actually a single tick is 100 nano secs based on MSDN and ist from the start of the century not 1970.

  4. #4
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: DateTime weird

    How are you determining that it is lower than DateTime.Now (and which "now" do you mean?)
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: DateTime weird

    Explain what you are trying to calculate... Not at all clear?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Jan 2010
    Posts
    1,133

    Re: DateTime weird

    Any chance you're testing along the lines of: DateTime.Now < EndTime?
    Because, that "Now" is a new "Now", and not the original "Now".
    If so, you need to store the result of DateTime.Now the first time you call it, and check against that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured