简体   繁体   中英

Date format :DB2

I know Current Date function gives mig date for Today CURRENT DATE ='2022-06-29' If I want to get the First date and Last date to current month how I can do it in DB2?

cast(JOB.FOMDATE as DATE), cast(JOB.TOMDATE as DATE)) OVERLAPS (cast(***'2022-01-01'*** as DATE), cast(***'2022-01-31'*** as DATE)) 

Thanks very much

Look at the following built-in functions:
FIRST_DAY
LAST_DAY

SELECT 
  D
, FIRST_DAY (D)                     AS D_FIRST
, D - DAY (D) + 1                   AS D_FIRST_ALT
, LAST_DAY (D)                      AS D_LAST
, D - (DAY (D) - 1) + 1 MONTH - 1   AS D_LAST_ALT
FROM (VALUES CURRENT DATE) T (D)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM