Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
create or replace function trunc (x timestamp) returns date language plpgsql as $function$ begin return date_trunc('year', to_date((to_char(coalesce($1, current_timestamp), 'YYYY-MM-DD')), 'YYYY-MM-DD')); end $function$; select trunc(now()::timestamp); select trunc(null::timestamp);

Stuck with a problem? Got Error? Ask AI support!

Copy Clear