Skip to content

Instantly share code, notes, and snippets.

@joebartels
Last active September 12, 2018 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joebartels/44808e47cee49762c103e8b691248714 to your computer and use it in GitHub Desktop.
Save joebartels/44808e47cee49762c103e8b691248714 to your computer and use it in GitHub Desktop.
store date fields (day of week, hour, minute) vs. using extract to query postgres
-- returns a random number from within a range (inclusive)
create or replace function int_between(
in low int,
in high int,
out int
)
returns int
language sql
as $$
select floor(random() * (high - low + 1) + low)::int
$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment