Skip to content

Instantly share code, notes, and snippets.

View mrunderline's full-sized avatar
🐢

Ali Madihi mrunderline

🐢
View GitHub Profile
@mrunderline
mrunderline / jalali-plpgsql.sql
Created September 25, 2023 10:07 — forked from ilius/jalali-plpgsql.sql
Jalali Date Conversion in PL/pgSQL
create or replace function epoch_to_jd(float) RETURNS int as $$
BEGIN
return ($1 / (24*3600) + 2440588)::int;
END;
$$ LANGUAGE plpgsql;
create or replace function timestamp_to_jd(timestamp with time zone) RETURNS int as $$
BEGIN
return epoch_to_jd(extract (epoch from $1));
END;