You must Sign In to post a response.
  • Category: .NET

    How do I find Time difference in milliseconds in vb.net

    Dear All,

    How do I find Time difference in milliseconds in vb.net , let us take

    StartTime and EndTime

    I want to find diff of (EndTime - StartTime) in milliseconds

    It's urgent, please tell me.

    Thanks in advance

    Shivaraj
  • #65025
    Hi Shivaraj

    You can use the DateDiff function

    Dim inSec, inMilliSec as Long
    inSec = DateDiff(DateInterval.Second,EndDateTime,StartDateTime)
    inMilliSec = inSec * 1000


    Regards
    Mahesh

  • #65041
    Hi Mahesh,

    Thanks for ans...

    how do u get seconds and milliseconds ... dont tell to use ... Now.TimeOfDay.TotalMilliseconds.ToString()

    see the below situation
    Login Start: 7/27/2006 11:25:28 AM Login End: 7/27/2006 11:25:31 AM

    if i use ur logic .. i will definitely get inMilliSec= 0


    startTime: HH:MM(min):SS(second):millisecond?(how do i get)
    11:25 :28 :????

    EndTime HH:MM(min):SS(second):millisecond?(how do i get)
    11:25 :28 :????

    diff of two =00 :00 :00 :????

    regards
    shivaraj

  • #71098
    Hi Shivaraj,

    You can use EndTime.Ticks - StartTime.Ticks

    Regards
    Mahesh


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.