Re: Plpgsql function to compute "every other Friday" - Mailing list pgsql-general

From C. Bensend
Subject Re: Plpgsql function to compute "every other Friday"
Date
Msg-id 4770a9359cf3f78d95c6cb4bddae269f.squirrel@webmail.stinkweasel.net
Whole thread Raw
In response to Re: Plpgsql function to compute "every other Friday"  ("David Johnston" <polobo@yahoo.com>)
List 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



pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Plpgsql function to compute "every other Friday"
Next
From: "C. Bensend"
Date:
Subject: Re: Plpgsql function to compute "every other Friday"