Results 1 to 3 of 3

Thread: [RESOLVED] Find the first day of the week?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Location
    Toronto
    Posts
    103

    Resolved [RESOLVED] Find the first day of the week?

    Hey,

    So I can't figure out how to find the first day of the week. I also need it in a format like ("yyyyMMdd")

    Right now I only have it telling me its Sunday. I need the exact date.

    Code:
      
    Dim FDW As Date
    FDW = WeekdayName(1, FirstDayOfWeek.System)
    MessageBox.Show(FDW)
    Anyone have an idea?

    Thanks,
    Sean

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Find the first day of the week?

    Code:
        Dim fdw As DateTime = DateTime.Today.AddDays(-Weekday(DateTime.Today, FirstDayOfWeek.System) + 1)
        MessageBox.Show(fdw.ToString("yyyyMMdd"))
    As you can see I use FirstDayOfWeek.System since in some countries Monday is considered to be the first day of the week and in others its Sunday.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Location
    Toronto
    Posts
    103

    Re: Find the first day of the week?

    Thanks! Works perfectly!

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