Results 1 to 4 of 4

Thread: Date Question - Visual Basic 6.0

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2002
    Location
    Florida, USA
    Posts
    56

    Question Date Question - Visual Basic 6.0

    Hello programmers:

    Please I need help.

    -- I am writing a process in which SUNDAY is the first day of the week

    -- I need to dectect the beginning of the last week. For example:

    a) 11/25/2002 (SUN) - 11/30/2002 (SAT). This is my last week

    b) 12/02/2002 is the current date

    I need to detect the firts day of the last week and add the date (mm/dd/yy) into an array. I am need to add only the Seven days.


    Can somebody help me how to acompllish this task.

    Thanks to all for your time
    Daniel
    Florida

  2. #2
    Member
    Join Date
    Oct 2002
    Posts
    33
    Hi !

    Hope this helps at least as a starting point :

    Code:
    For i = 1 To -7 Step -1
        If WeekDay ( Date + i )= 1 Then    ' 1 = Sunday... 7 = Saturday
            Text1 = Date + i ' Store in Text Box for you to move it somewhere else
            Debug.Print Date + i ; " was Last Sunday"
            End If
        Next i

  3. #3
    Member
    Join Date
    Oct 2002
    Posts
    33
    I was thinking about my own problems moving day by day for some specific reasons ( I do some "time measuring" with very special behaviours ).

    If all you need is last Sunday you could use this one :

    Code:
    Text1 = Date - WeekDay ( Date ) + 1
    and if needed some Sundays before ( or after ) you can just subtract ( or add ) 7, 14, etc. in a loop as long as you need.

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2002
    Location
    Florida, USA
    Posts
    56

    Thumbs up Thanks

    Thanks alot for your advice and time. It woks well.


    Daniel
    Hollywood, FL
    Daniel
    Florida

Posting Permissions

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



Click Here to Expand Forum to Full Width