General discussion

Locked

in VB6 how many days between 2 date?

By khalid ·
I want to know for example how many Sunday days between two days

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

in VB6 how many days between 2 date?

dim lngDateDiff as long
'Date2 is later date
lngDateDiff=dtDate2-dtDate1
Hope this helps
John

Collapse -

in VB6 how many days between 2 date?

by khalid In reply to in VB6 how many days betw ...

i don't mean i want to know how many days but i mean i want to know how many sunday or monday between two date

Collapse -

in VB6 how many days between 2 date?

Sorry, didn't read the question properly.
Use the weekday function to determine the day of the week, add the appropriate number of days to get to the first Sunday. Your answer should be int(dtDate2-dtFirstSunday).
Haven't actually tried it out but it should work. Also, you may not want to count the original first date if it is a Sunday.

Collapse -

in VB6 how many days between 2 date?

by khalid In reply to in VB6 how many days betw ...

Poster rated this answer

Collapse -

in VB6 how many days between 2 date?

by RSV In reply to in VB6 how many days betw ...

Dim d1 As Date
Dim d2 As Date
Dim dd As String
Dim c As Integer
Dim i As Integer
d1 = Date
d2 = "06/15/2001" 'mm/dd/yy
dd = DateDiff("d", d2, d1, vbSunday, vbUseSystem)
For i = 0 To Int(dd) - 1
dd = Weekday(DateAdd("d", i, d2), vbSunday)
If dd = 1 Then
c = c + 1
End If
Next
MsgBox "Total Sundays between " & d2 & " and " & d1 & " are " & c

Hope this helps you.
GOOD LUCK...:)

Collapse -

in VB6 how many days between 2 date?

by khalid In reply to in VB6 how many days betw ...

thank you very much

Collapse -

in VB6 how many days between 2 date?

by khalid In reply to in VB6 how many days betw ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums