Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

calculate a specific day of the week

Discussion in 'Information Technology' started by Dendalee, Jul 28, 2006.

  1. Dendalee

    Dendalee
    Expand Collapse
    Guest

    I need to calculate from the entry date of a youth the specific date of the
    Tuesday within a 30 day limit.

    The youth in our program must see the doctor within 30 days, however, the
    doctor is only in the office on Tuesdays. I want to calculate the nearest
    Tuesday to the 30 day mark.

    Thanks,

    Dendalee
     
  2. Loading...

    Similar Threads Forum Date
    India Reading Calculated Banis Breaking News Mar 6, 2013
    Is Sikhism a Universal Religion or a Culturally Specific One? Sikh Sikhi Sikhism Feb 22, 2010

  3. Bill Edwards

    Bill Edwards
    Expand Collapse
    Guest

    Public Function Tuesday30(datDate As Date) As Date
    On Error GoTo Err_Label
    Dim datThirtyDays As Date
    datThirtyDays = DateAdd("dd", 30, datDate)
    Do While Weekday(datThirtyDays, vbSunday) <> 3
    datThirtyDays = DateAdd("d", -1, datThirtyDays)
    Loop
    Tuesday30 = datThirtyDays

    Exit_Label:
    Exit Function
    Err_Label:
    MsgBox Err.Description
    Resume Exit_Label
    End Function

    "Dendalee" <Dendalee@discussions.microsoft.com> wrote in message
    news:05343D88-8FD9-407B-8DFB-BD0BC32F8471@microsoft.com...
    >I need to calculate from the entry date of a youth the specific date of the
    > Tuesday within a 30 day limit.
    >
    > The youth in our program must see the doctor within 30 days, however, the
    > doctor is only in the office on Tuesdays. I want to calculate the nearest
    > Tuesday to the 30 day mark.
    >
    > Thanks,
    >
    > Dendalee
     
  4. Valentín Playá

    Valentín Playá
    Expand Collapse
    Guest

    Dendalee,

    this function returns the nearest Tuesday in 30 days.

    =iif(weekday([fecha1]+30;3)<5;
    [fecha1]+30+(1-weekday([fecha1]+30;3));
    [fecha1]+30+(8-weekday([fecha1]+30;3)))

    were Fecha1 is the date to calculate from.

    or you may put this function in a module

    Function Tuesday30(DateFrom As Date) As Date
    Tuesday30 = DateFrom + 30
    If Weekday(Tuesday30, 3) < 5 Then
    Tuesday30 = Tuesday30 + (1 - Weekday(Tuesday30, 3))
    Else
    Tuesday30 = Tuesday30 + (8 - Weekday(Tuesday30, 4))
    End If
    End Function

    and call as Tuesday30(Fecha1) from a query or a form.

    Regards,

    Valentín Playá
    Sonotronic S.A.
    Madrid, Spain
     

Share This Page