Excel VBA Basics #24 DateDiff in VBA - Difference in Seconds, Hours, Weekdays, Quarters, Months, Etc

preview_player
Показать описание

Find the difference between two dates/times. Find out how many hours, seconds, quarters, months, years, weekdays, weeks, days, whatever!! You can calculate using similar descriptions as with DateAdd:

s Seconds
n Minutes
h Hours
d Days
w Weekdays
ww Weeks
m Months
q Quarters
y Days of the year
yyyy Years

Fantastic Developer Tools:
Рекомендации по теме
Комментарии
Автор

Perfect for my payroll requests application. Will completely change my functions...
Thanks dude!!!

TonyDiaz.
Автор

Merry Christmas everyone. I hope God blesses you richly this upcoming year. Remember, you ARE a success!! Believe it, be it! Blessings my friends!! Dan

ExcelVbaIsFun
Автор

how do you use datediff that shows the elapsed minutes with 2 decimals?

FRAN-vdrl
Автор

Could you tell me how to show the answers in the cell of the Excel sheet?

髙橋孝義
Автор

how we can do datedif not datediff
coz i wana the day in range 365

mohamadhabibhomeidi
Автор

My excel on this code returns 15-4-1900.

Any idea?

Dim roznica As Integer
Dim obecna As Date, dzisiaj As Date
obecna = [h8]
dzisiaj = [l1]

roznica = DateDiff("d", obecna, dzisiaj)

BLNSKY
Автор

I'm trying to get this to work in a userform. Date is entered into txt_DOS. want txt_countweeks to be the number of weeks since the txt_dos.
private sub txt_dos_afterUpdate()
Dim dbsht As Worksheet
Set dbsht =
date1=dbsht.txt_dos.text
date2=Now()
dbsht.txt_countweeks= DIffDate("w", date1, date2)
end sub;

Any help from anyone in the community here is much appreciated. I'm banging my head on the keyboard right now.

mellowkoopa