Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[db2][sql] ermitteln datum des vormonats

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

bin grad am verzeifeln un deshalb werde ich mal die Frage hier stellen:

Ich brauche an jedem beliebigen Tag im Monat (CURRENT_DATE) das Datum des ersten und des letzten Tages des Vormonats berechnet (als typ DATE).

Das ganze als SQL Statement in db2 (das is erstmal zweitrangig).

Jmd ne Idee?

Moin!

Das gibt dir den Letzten des vergangenen Monats zurück:


mysql> select current_date - interval dayofmonth(current_date) DAY 

    -> AS Letzter_des_vorigen_Monats;

+----------------------------+

| Letzter_des_vorigen_Monats |

+----------------------------+

| 2006-10-31                 |

+----------------------------+

Das Andere sehen wir Morgen. Will ja auch mal Feierabend haben ;)

Hey,

danke soweit!

Ich hab jetzt auch ne Lösung gefunden ;)

ganz einfach, wenn ich einfachhalber den Job immer am 1. des Monats laufen lasse:


select current_date - 1 month as "1. des monats"

         last_day(current_date - 1 month) as "letzter des monats"

...

hab wohl etwas aufm Schlauch gestanden ;)

Danke!

also nochmal die richtige Lösung zur Fragestellung

1. Tag des letzten Monats

LAST_DAY(CURRENT_DATE - 2 MONTH) + 1 DAY
letzer Tag des letzen Monats
LAST_DAY(CURRENT_DATE - 1 MONTH)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.