Results 1 to 4 of 4

Thread: *RESOLVED* Given a date return the date of Monday the same week

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819

    *RESOLVED* Given a date return the date of Monday the same week

    I'm stumped. The title says it all.

    I need the date of Monday for the same week as any date entered. I'm using the system settings for the first day of week.

    For some reason I can get it to work unless the day selected is the first day of the week. In that case it always selects the monday of the previous week. For all other dates it works fine.

    VB Code:
    1. dMonday = DateAdd("d", -Weekday(dSelectedDate, vbMonday) + 1, dSelectedDate)
    Last edited by cafeenman; Jul 7th, 2002 at 08:06 PM.

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    It worked for me.... maybe the month and day are messed up.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    USe this:

    VB Code:
    1. dMonday = DateAdd("d", -(Weekday(dSelectedDate, vbUseSystemDayOfWeek) - dSelectedDate), dSelectedDate)


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  4. #4

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    OK, this gets it.

    VB Code:
    1. dStartDate = DateAdd("d", Weekday(vbMonday) - Weekday(mvSchedule.Value), mvSchedule.Value)

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