0

I am trying to add filters to my charts. How can I add a filter if my input is dates? For example I want to be able to filter to just the year of 2022 or I want to be able to look between the days of XX/XX/XXXX-XX/XX/XXXX

My input type is date but I only know how to filter by names at the moment using a command like this:

Paint_shop = :P9_Select_Shop

bbowen14
  • 37
  • 5

1 Answers1

1

For years:

where extract(year from date_column) = 2022

For dates (as Apex items' datatype is char, presuming you set format model to dd.mm.yyyy):

where date_column between to_date(:P1_DATE_FROM, 'dd.mm.yyyy')
                      and to_date(:P1_DATE_TO  , 'dd.mm.yyyy')
Littlefoot
  • 131,892
  • 15
  • 35
  • 57
  • Hey, I am a little confused, what would the "to_date" be? I am assuming "date_column" is the column where data is stored – bbowen14 Mar 24 '22 at 16:02
  • TO_DATE is a function that converts other datatypes (such as NUMBER or VARCHAR2) to a valid DATE datatype value, when you apply correct format model. DATE_COLUMN: yes, that's it; you didn't post table description so I "suggested" column's name. – Littlefoot Mar 24 '22 at 16:14
  • The data type is "Date" Could this be why I am having trouble. Would VARCHAR be a better use for data entry in this instance? – bbowen14 Mar 24 '22 at 16:41
  • Dates should be stored into a DATE datatype column. Applying TO_DATE to a DATE datatype value is wrong. But in Apex, all items act as if they were strings - that's why you have to apply TO_DATE to page items. – Littlefoot Mar 24 '22 at 17:35
  • Thank you so much for your help I was able to figure it out – bbowen14 Mar 25 '22 at 12:55