2 Replies - 595 Views - Last Post: 16 January 2011 - 01:25 AM Rate Topic: -----

#1 Mohanan_V  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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!!!

:code:

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  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,262
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • 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!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1