Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page