about timestamp

Hello everyone,


I need to record a set of data items. For each data item, users may modify to some new content. So, I plan to use a timestamp field for each data item to record the time when user modifies data item last time.

I am not sure whether I should use a simple integer value (like version information, which increase 1 each time when user modifies data item)

Which approach is better What are the advantages and disadvantages of each approach


thanks in advance,
George


Answer this question

about timestamp

  • CHOULANT Noham

    Try multimedia timer - it must have high resolution. See timeGetTime function.
  • seadur

    Hi Alex,

    Alex Farber wrote:
    Try multimedia timer - it must have high resolution. See timeGetTime function.

    Using such function requires hardware support I mean my computer has to have a high resolution timer/clock

    regards,

    George


  • ALFKI

    Timestamp is better if you want to sort items by modification time.
  • roundandround

    Windows Mobile supports this

    Alex Farber wrote:
    Try multimedia timer - it must have high resolution. See timeGetTime function.

    regards,

    George


  • MrZap

    Thank you Chris,

    Chris Hird wrote:

    I tried to use the time stamp but found it did not work in my case. the problem I had was the process ran so quickly that retrieving the current date and time resulted in a lot of entries with the same time stamp. Even trying to get the ticks which should have been every 100 nanoseconds didnt give the desired result I even tried to add 1 second in the hope the string would be different but it wasnt. Could be my logic or my code

    // create a time stamp

    DateTime tStamp = DateTime::Now;

    //tStamp = tStamp.AddSeconds(1);

    __int64 ticks = tStamp.Ticks;

    // add time stamp to beginning of the string

    String* tmStamp = ticks.ToString();

    This was wrapped in a for loop with a read of data from a file before this everytime.

    You have given us a good point why timestamp is not very suitable. What makes me confused is that why even 100 nano-seconds is not enough to produce a difference It should be a *long* time for the computer. :-)

    regards,

    George


  • Hippunky

    Thank you Alex,

    Alex Farber wrote:
    Timestamp is better if you want to sort items by modification time.

    Do you mean using timestamp is always better Actually, I do not have such requirements.

    regards,

    George


  • kmoreto

    I tried to use the time stamp but found it did not work in my case. the problem I had was the process ran so quickly that retrieving the current date and time resulted in a lot of entries with the same time stamp. Even trying to get the ticks which should have been every 100 nanoseconds didnt give the desired result I even tried to add 1 second in the hope the string would be different but it wasnt. Could be my logic or my code

    // create a time stamp

    DateTime tStamp = DateTime::Now;

    //tStamp = tStamp.AddSeconds(1);

    __int64 ticks = tStamp.Ticks;

    // add time stamp to beginning of the string

    String* tmStamp = ticks.ToString();

    This was wrapped in a for loop with a read of data from a file before this everytime.


  • jxl98c

    Yes, but I don't think that you can find computer which doesn't support this.


  • about timestamp