excel vba - I can't use datediff vba -


example input:

date1 = "2015-03-23 07:06:17.855000" date2 = "2015-03-23 07:06:17.870000" 

when use

ans = datediff("s", date1, date2) 

it produces error: type mismatch

how can fix this?

doesn't you've got successful answer yet, here's possibility.

dim t() string dim d1 long dim d2 long  date1 = "2015-03-23 07:06:17.855000" date2 = "2015-03-23 07:06:17.870000" t = split(date1, ".")   'use "." split off miliseconds d1 = clng(t(2))         'grab milliseconds, convert long t = split(date2, ".")   'use "." split off miliseconds other date d2 = clng(t(2))         'grab milliseconds, convert long  msgbox "difference in milliseconds: " & cstr(d2-d1) 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -