3 Replies - 558 Views - Last Post: 22 January 2014 - 02:14 PM Rate Topic: -----

#1 jose.rodriguez.an  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 18-April 13

Calculate 10 days from current day minus weekends

Posted 22 January 2014 - 01:43 PM

Hi all,

I need to calculate the date 10 days after the current date minus the weekends.

Someone could help me?. .
Is This A Good Question/Topic? 0
  • +

Replies To: Calculate 10 days from current day minus weekends

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9574
  • View blog
  • Posts: 36,262
  • Joined: 12-June 08

Re: Calculate 10 days from current day minus weekends

Posted 22 January 2014 - 01:48 PM

What have you tried/looked into/etc?
Was This Post Helpful? 0
  • +
  • -

#3 jose.rodriguez.an  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 18-April 13

Re: Calculate 10 days from current day minus weekends

Posted 22 January 2014 - 02:09 PM

I have this code i am using for the opposite, and I discounting the weekends. But now I have to do the opposite and i am broken my mind and I cant achieve what i want.

Private Sub DateCC1TP_ValueChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateCC1TP.ValueChanged
        Dim startdate As Date = DateCC1TP.Value
        Dim Finishdate As Date = Now.Date
        Dim offday As Byte = 0

        'Calcular fechas CC1
        Dim dias As Long = DateDiff(DateInterval.Day, startdate, Finishdate)

        If startdate > Finishdate Then
            CalTxt.Text = 0
            MsgBox("Date is higher than actual", MsgBoxStyle.OkOnly)
        ElseIf startdate <= Finishdate Then
            'Bucle para contar los fines de semana 
            Do
                'Resta dos para los fines de samana
                If startdate.DayOfWeek = DayOfWeek.Sunday Then
                    offday += 2
                End If
                startdate = startdate.AddDays(1)

            Loop Until startdate > Finishdate

            'Añadir dia de inicio y de hoy.
            dias += 2
            'Restar dias de fiesta
            dias -= offday

            CalTxt.Text = dias & " days"
        End If
    End Sub

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9574
  • View blog
  • Posts: 36,262
  • Joined: 12-June 08

Re: Calculate 10 days from current day minus weekends

Posted 22 January 2014 - 02:14 PM

Perhaps you need to take a break from the code then?

Aside from the programming of one case - what is your general logic for this new case? Do you have that much?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1