Suche nach dem start-Tag (Montag) der aktuellen Woche

Suche nach einem SQL query/Abfragen, würde das bestimmen der start-Tag (Montag) der aktuellen Woche.

Beispiel:
Wenn heute -> dann der start der Woche ist

Sat Oct 09, 2010 -> Start of the week is Monday Oct 04, 2010
Sun Oct 10, 2010 -> Start of the week is Monday Oct 04, 2010
Mon Oct 11, 2010 -> Start of the week is Monday Oct 11, 2010
Tue Oct 12, 2010 -> Start of the week is Monday Oct 11, 2010

Habe ich gesehen, dass viele "Lösungen" bei Google und StackOverflow. Das Aussehen:

SET @pInputDate = CONVERT(VARCHAR(10), @pInputDate, 111)
SELECT DATEADD(DD, 1 - DATEPART(DW, @pInputDate), @pInputDate)

Diese schlägt fehl, weil:
Sun Oct 10, 2010 -> start der Woche am Montag Okt 11, 2010 (was ist falsch).

  • Brauchen Sie nur Montag oder am ersten Arbeitstag der Woche?
  • Ich möchte den Anfang der Woche (Montag) unabhängig davon, ob es ein Arbeitstag oder ein Feiertag.
InformationsquelleAutor del.ave | 2010-10-14
Schreibe einen Kommentar