SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create or replace function trunc (x timestamp) returns date language plpgsql as $function$ begin select date_trunc('year', to_date((to_char($1, 'YYYY-MM-DD')), 'YYYY-MM-DD')) exception, -- when undefined_column then select date_trunc('year', current_timestamp::date) end ; $function$;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear