I have a table for orders and it has 2 column with DATE types: delivery_date and order_date. In my sqldeveloper, all the dates I've inserted via Java or by hand are in the format 10.01.25 for the 25th Jan of this year. When I try to see the the total_price for orders between one date and another, I force the format like this:
create or replace function calc_Outlays (init_date IN DATE,final_date IN date)return number is
v_total_enc FORNECIMENTO.TOTAL_ENC_FORNEC%TYPE;
begin
select f.total_enc_fornec into v_total_enc from fornecimento f where f.data_entrega between init_date and final_date;
return v_total_enc;
Exception
When no_data_found then
Insert Into errors Values (0,'No supplyment costs found for dates between '||to_char(init_date)||' and '||to_char(final_date),systimestamp);
return -1;
end;
but I get -1 returned. I even try to do the query like this: select f.total_enc_fornec from fornecimento f where f.data_entrega = '10.01.24';
like this: select f.total_enc_fornec from fornecimento f where f.data_entrega = to_date('10.01.24','yy-mm-dd');
like this: select f.total_enc_fornec from fornecimento f where f.data_entrega < to_date('10.01.24');
and NOTHING is returned!
but if I execute : select f.total_enc_fornec from fornecimento f where f.data_entrega <= sysdate;
it prints a result as it's supposed to...
How can I do this? I'm clearly not passing correctly the parameters nor in the function, neither executing the query itself
Btw, and if I wanted to select ALL the orders of some year/month/day? Say, using extract function for example. Could you please show me how? I've tried, but I'm having the same problems and I it's simple in concept, at least, lol.