Home Difference of dates
Reply: 0

Difference of dates

user920
1#
user920 Published in July 17, 2018, 7:50 am

There are two dates(one over the second). I want to know the difference between them (in days).Programm produces the value “0”. Error in the variables vat1,vat2. Tell me , how to set them correctly ?

   Sub ógv()
   Dim dat1 As Date
   Dim dat2 As Date
   Dim vat1 As Date
   Dim vat2 As Date
   Dim Day1 As Long
   Dim Month1 As Long
   Dim Year1  As Long
   Dim Day2 As Long
   Dim Month2 As Long
   Dim Year2  As Long
   Dim C As Range

   Set C = ThisWorkbook.ActiveSheet.Range("C35")
   '1
   dat1 = C.Value
   Day1 = DatePart("d", dat1)
   Month1 = DatePart("m", dat1)
   Year1 = DatePart("yyyy", dat1)
   vat1 = Month1 / Day1 / Year1
   '2
   dat2 = C.Offset(-1, 0).Value
   Day2 = DatePart("d", dat2)
   Month2 = DatePart("m", dat2)
   Year2 = DatePart("yyyy", dat2)
   vat2 = Month2 / Day2 / Year2


    Dni = DateDiff("d", vat2, vat1)
     MsgBox Dni

  End Sub
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313069 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO