From: | "C(dot) Bensend" <benny(at)bennyvision(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Plpgsql function to compute "every other Friday" |
Date: | 2011-04-05 01:26:32 |
Message-ID: | 4770a9359cf3f78d95c6cb4bddae269f.squirrel@webmail.stinkweasel.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> It is a very simplistic approach since you do not take into account
> holidays. But if it meets your needs what you want is the modulo operator
> (
> "%"; "mod(x,y)" is the equivalent function ) which performs division but
> returns only the remainder.
>
> N % 14 = [a number between 0 and (14 - 1)]
>
> N = 7; 7 % 14 = 7 (0, 7 remainder)
> N = 14; 14 % 14 = 0 (1, 0 remainder)
> N = 28; 28 % 14 = 0 (2, 0 remainder)
> N = 31; 31 % 14 = 3 (2, 3 remainder)
Ah, thank you, David. This gives me some good knowledge that I
was missing! I know about %, but I was fumbling a bit with it in
plpgsql, and your examples helped.
Thanks!
Benny
--
"Hairy ape nads." -- Colleen, playing Neverwinter Nights
From | Date | Subject | |
---|---|---|---|
Next Message | C. Bensend | 2011-04-05 01:32:07 | Re: Plpgsql function to compute "every other Friday" |
Previous Message | John R Pierce | 2011-04-05 01:16:23 | Re: Plpgsql function to compute "every other Friday" |