On Wed, Dec 14, 2016 at 2:17 PM, Patrick B <patrickbake...@gmail.com> wrote:
> > As you can see, I select a date. So in December, the date will be: *BETWEEN > '201612015' AND '201601015'*, for example. > > That is an unusual timestamp value...what's the 5 for? (I've figured this out...but its still unusual) > > > 1. Why when I run the function manually I get this error? > > select logextract(201612015, 201612015); > > ERROR: operator does not exist: timestamp without time zone >= integer > > LINE 13: BETWEEN > > > I presume this is wrong: *CREATE or REPLACE FUNCTION > logextract(date_start integer, date_end integer) *- But what should I use > instead? > > I don't understand why "date" wouldn't be your first choice here. Or, better yet, a single argument of type daterange. > 2. To call the function, I have to login to postgres and then run: select > logextract(201612015, 201612015); > How can I do it on cron? because the dates will be different every time. > > PostgreSQL knows what the current date is so describe how to compute your desired boundaries given a single date. Dates and times are their own types in PostgreSQL. They are incompatible with integers. You either to convert one or the other if you want to perform a comparison. David J.