Automation of code

Asked

Viewed 22 times

0

Using a DB2 database

I need to automate a query and currently have the following scenario:

SELECT * FROM tabela WHERE DATA1 < '2020-06-01' AND DATA2 >= '2020-05-01'

How to make date conditions always be:

DATA1 = the first day of the following month

DATA2 = the first day of the current month

1 answer

1

One possibility is to use the function date_trunc('month', now()) to get the start of the current month and add_months(date_trunc('month', now()), 1) to obtain the beginning of the following month.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.