I am querying a file with dates in YYYY-MM-DD format but are formatted as character. If I just run a simple query like with WHERE DATE_IN_FILE >= '2022-01-31' that works. However I need to make that date a parameter so it does not have to be hardcoded. I've created the parameter like this: select trim(to_char(to_date(trim(date_today),'yyyymmdd')+1,'yyyy-mm-dd')) into v_eff_dt from model_input_param date_today is formatted as character also in yyyymmdd format, ex. 20220630. So I want to compare date_in_file to v_eff_dt. I've tried multiple ways to do this and nothing seems to work. Here's some of what I've tried:
- to_date(DATE_IN_FILE, 'YYYYMMDD') <= to_date(V_EFF_DT,'YYYYYMMDD')
- DATE_IN_FILE <= V_EFF_DT
- to_date(DATE_IN_FILE,'YYYY-MM-DD') <= to_date(V_EFF_DT,'YYYY-MM-DD')
Hoping to get some help. thanks
Lets say you have these data in (external) file
Now in Netezza you can read these on the fly (or create an external table and then read)
Now you can store your parameter in a table and then filter like this
But this depends on
v_eff_dtalways having 1 row to be effective. Its much better to just do