SQLTeam.com | Weblogs | Forums

How to select current month using between

#1

How to select current month based on GetDate -1 ?
and how to display in the format of YYYYMMDD
note, i need to use between 2 date for this script instead of select by month.

eg:
if today is 6 May 2019; then system should select the PaymentDate from 1 May 2019 until 31 May 2019

where (To_date(PAYMENT_DATE) between TO_DATE('20190501','YYYYMMDD') and TO_DATE('20190530','YYYYMMDD')


if today is 1 May 2019; then system will count as date 1 May 2019 - 1day; then system should select the PaymentDate from 1 Apr 2019 until 30 Apr 2019

where (To_date(PAYMENT_DATE) between TO_DATE('20190401','YYYYMMDD') and O_DATE('20190430','YYYYMMDD')