April 2, 2023

3 thoughts on “Microsoft Excel Tutorial: WEEKDAY Function

  1. I have created this function to get first date of week as Thursday in ms access form and reports, but this function return first day of week in las month, but I need it will return only current month dates, if current week first day is in last month then retrun first day of week as 1st date of week in current month.

    ‘current output

    ‘when 1-10-2018 is selected from date picker it returns 27-09-2018, which is first date of week in last month but I need it will return 1st of month which is selected in textbox.

    Function GetFirstofWeek(dtDate As Date)

    'GetFirstofWeek = DateAdd("d", dtDate, -(Weekday(dtDate)) + 1)

    ' Excel formula for this function which is perfect and may be converted to function as required ‘=MAX(B2-WEEKDAY(B2,14)+1, EOMONTH(B2, -1)+1)

    GetFirstofWeek = DateAdd("d", dtDate, -(Weekday(dtDate, vbThursday) – 1))

    End Function

    'For last day of week

    Function GetLastofWeek(dtDate) as date

    '=MIN(B2+(7-WEEKDAY(B2,14)), EOMONTH(B2, 0))

    GetLastofWeek = DateAdd("d", dtDate, (7 – (Weekday(dtDate, vbWednesday)) + 1))

    End Function

    In this function last date of week must be in current month, if month end on first date of then week will be closed and last date of week will be 1st date of week or days remaining in current week.

  2. Thanks for the great job you are doing to share your knowledge in Excel.
    I really appreciate if you can help me out with one issue I am having at work.
    I need to figure out a formula that gives me a date, depending on weekdays.
    So, I have in one row the dates of the delivery of our orders, and next to that cell, there should be that date + 5 weekdays, which is our maximum period of time since we get the order till we ship the goods.
    I really really appreciate your comments.
    Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *