How to get a Date Difference Value in milliseconds in VBA

mfaqueiroz

New Member
Joined
Sep 30, 2015
Messages
5
Hei,
I've one table with dates in this format dd:mm:yyyy hh:mm:ss and in another column the milliseconds.

Do you have any suggestion how can I make the time difference in milliseconds?

I've done in this way..but ins't working for some cases

If Ms2 > Ms1 Then
Dif = DateDiff("s", Time1, time2)
Difms = ms2 - ms1
Dif= (Dif * 1000) + Difms

Else
Dif = DateDiff("s", Time1, time2)
Difms = (ms2 - ms1) + 1000
Dif = ((Dif - 1) * 1000) + Difms


Thank in advance for your help!
smile.gif
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
How about:
Code:
[COLOR=#000000][FONT=verdana]If Ms2 > Ms1 Then[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]    Dif = (DateDiff("s", Time1, time2)) * 1000[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]Else[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]    Dif = (DateDiff("s", Time2, time1)) * 1000[/FONT][/COLOR]
[FONT=verdana][COLOR=#000000]End If[/COLOR][/FONT]
 
Upvote 0
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #10 here: http://www.mrexcel.com/forum/board-announcements/99490-forum-rules.html). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #10 here: http://www.mrexcel.com/forum/board-announcements/99490-forum-rules.html). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

I totally agree that if you are cross posting to be sure and state that with links to the other cross posts.

I have made over 10k replies post on Access forums in the past 10 years. Many of the Access experts/gurus monitor many of the Access forums. I post regularly on about 10 sites. I see a lot of the same people on multiple sites. By posting on one active site, it has almost the same reach to top experts as cross posting. I will reach out to others if I think they can help. Several of the site I post on regularly have a by invitation "VIP" hidden forum that only VIPs can access. This is VIP forum is often used to reach out to other VIPs for assistance.

After 10 years of reading over 100,000 questions by other (I have ask less that 5 questions about Access during the 10+ years) that most of the Access sites, like this one, are great discussion forums. Cross posting to multiple site all at the same time can result is less discussion which can lead to the best solution. It is best to post to one site and be patient. Only after a few days with no response or no solution would you want to cross post to one other site. with a link to the original. Then be patient again and wait. From experience, I have seen this work well. I have also seen the "shotgun" blast of cross posts all at the same time end up with no solution. Cross posting should be a last resort.
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,457
Members
452,515
Latest member
nguyenkim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top