dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Determine Last Sunday of Month ?

  1. #1
    Join Date
    Mar 2002
    Posts
    13

    Red face Determine Last Sunday of Month ?

    Guys, Do you have any piece of cide to determine the last sunday of any given month ?
    Actually I want to find the day the daylight time chnages dynamically. Since we know that it is on the last sunday of cotober,If I could find the last sunday of any given month in a given year I can do it.
    Any idea folks ?


    San.

  2. #2
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329
    ?dateadd("d",1 - weekday("2002-11-01"),"2002-11-01")

    Or whatever first day of whatever month of whatever year as appropriate.
    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

  3. #3
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Also use WeekDay() function to see if the day is a Sunday

    Code:
        '1 = Sunday
        '7 = Saturday
        MsgBox Weekday("2002/09/14")
    JeffB
    CodeGuru VB FAQ Visual Basic Frequently Asked Questions
    VB Code color Tool to color your VB code on CodeGuru
    Before you post Importants informations to know before posting

  4. #4
    Join Date
    May 2002
    Posts
    40
    Try this

    ---------------------------------------------------------------------
    Function LastSundayOfTheMonth(FirstDayOfNextMonth)
    If Weekday(FirstDayOfNextMonth) = 1 Then
    LastSundayOfTheMonth = DateAdd("d", _
    Weekday(FirstDayOfNextMonth) - 8, _
    FirstDayOfNextMonth)
    Else
    LastSundayOfTheMonth = DateAdd("d", _
    1 - Weekday(FirstDayOfNextMonth), _
    FirstDayOfNextMonth)
    End If
    End Function
    ---------------------------------------------------------------------

    efi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)