# Periods between given sets of dates

Page 1 of 1

## 2 Replies - 875 Views - Last Post: 16 January 2011 - 01:25 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=210160&amp;s=ede37dbcf790e4f4ee9697cd9bb0b373&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Mohanan_V

Reputation: 0
• Posts: 1
• Joined: 15-January 11

# Periods between given sets of dates

Posted 15 January 2011 - 09:02 PM

```Private Sub brocken()
Dim brokenDays1, brokenDays2, brokenDays3, brokenDays4, brokenDays5 As Integer

If txt1.Text = "" Then
Exit Sub
ElseIf brokenDays1 = CInt((DateValue(Format(txt2.Text, "DD/MM/YYYY")) - DateValue(Format(txt1.Text, "DD/MM/YYYY")))) + 1 Then
brokenDays5 = brokenDays1
ElseIf txt3.Text = "" Then brokenDays5 = brokenDays1
ElseIf brokenDays2 = brokenDays1 + CInt((DateValue(Format(txt4.Text, "DD/MM/YYYY")) - DateValue(Format(txt3.Text, "DD/MM/YYYY")))) + 1 Then
brokenDays5 = brokenDays2
ElseIf txt5.Text = "" Then brokenDays5 = brokenDays2
ElseIf brokenDays3 = brokenDays2 + CInt((DateValue(Format(txt2.Text, "DD/MM/YYYY")) - DateValue(Format(txt1.Text, "DD/MM/YYYY")))) + 1 Then
brokenDays5 = brokenDays3
ElseIf txt7.Text = "" Then brokenDays5 = brokenDays3
ElseIf brokenDays4 = brokenDays3 + CInt((DateValue(Format(txt2.Text, "DD/MM/YYYY")) - DateValue(Format(txt1.Text, "DD/MM/YYYY")))) + 1 Then
brokenDays5 = brokenDays4

ElseIf txt9.Text = "" Then brokenDays5 = brokenDays4
Else: brokenDays5 = brokenDays4 + CInt((DateValue(Format(txt2.Text, "DD/MM/YYYY")) - DateValue(Format(txt1.Text, "DD/MM/YYYY")))) + 1
End If

MsgBox brokenDays5

End Sub
```

MOD EDIT: When posting code...USE CODE TAGS!!!

This post has been edited by JackOfAllTrades: 15 January 2011 - 09:05 PM

Is This A Good Question/Topic? 0

## Replies To: Periods between given sets of dates

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 12316
• Posts: 45,416
• Joined: 27-December 08

## Re: Periods between given sets of dates

Posted 15 January 2011 - 10:37 PM

And your specific problems or errors are? A code dump is not a good way to get help.

### #3 maj3091

• D.I.C Lover

Reputation: 330
• Posts: 1,998
• Joined: 26-March 09

## Re: Periods between given sets of dates

Posted 16 January 2011 - 01:25 AM

Try looking at the DATEDIFF function, which will allow you to find the difference between two dates.

Not sure if that's what you're after, as macosxnerd101 has pointed out, you haven't exactly told us what your problem is!