Calculate first and last day of week

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CDeCinko
    New Member
    • Feb 2008
    • 2

    Calculate first and last day of week

    How do I get the date for the first and last day of the week, and the first and last day of last week?
  • cori25
    New Member
    • Oct 2007
    • 83

    #2
    • The first day of the current week (assuming Sunday = day 1):
    Date() - WeekDay(Date()) + 1

    • The last day of the current week:
    Date() - WeekDay(Date()) + 7

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      FirstDayOfCurre ntWeek = SomeDate-(weekday(SomeDa te)-1)
      FirstDayOfPrevi ousWeek = SomeDate-(weekday(SomeDa te)-1)-7

      LastDayOfCurren tWeek = SomeDate - Weekday(SomeDat e) + 7
      LastDayOfPrevio usWeek = SomeDate - Weekday(SomeDat e)

      You can enter an actual date for SomeDate or use Date() to base this on today when run.

      Welcome to TheScripts!

      Linq ;0)>

      Comment

      • ahmadMBAAAA
        New Member
        • Sep 2022
        • 1

        #4
        Hi, can you help me here, I'm trying to start the same one but with start day next Sunday and the end date end next week on Saturday in the format of dd.mm.yyyy. As I'm connecting this to sap script.

        Can you assist here?

        Comment

        Working...