From: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
To: A. Kretschmer <andreas.kretschmer@schollglas.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Between and miliseconds (timestamps)
Date: Fri, 10 Nov 2006 16:34:27 -0200
Message-ID: <55c095e90611101034r7dc6bf1btba72aa24f9300593@mail.gmail.com> (raw)
In-Reply-To: <20061110152427.GA3634@a-kretschmer.de>
References: <55c095e90611100628m1322eea5jeeca3a94d90e1eb1@mail.gmail.com>
<20061110144458.GA2909@a-kretschmer.de>
<55c095e90611100650q3ec0ec27tc0f8e94a0eb032eb@mail.gmail.com>
<20061110152427.GA3634@a-kretschmer.de>
Ok thank you very much, but the suggestion (SQL:when field =
'2006-09-06'::date) does not retrieve any row. It does not retrive any error
too, but the suggestion does not applied to my requisition.
The second suggestion is quite correct but I would like to use the between
expression.
Best regards to both
Ezequias
2006/11/10, A. Kretschmer <andreas.kretschmer@schollglas.com>:
>
> am Fri, dem 10.11.2006, um 12:50:38 -0200 mailte Ezequias Rodrigues da
> Rocha folgendes:
> > > select * from base.table
> > > where when
> > > between
> > > '2006-09-06 00:00: 00.000000'
> > > and
> > > '2006-09-06 23:59:59.999999'
> > > order by 2
> > >
> > > Is there a simplest way or not ?
> >
> > Yes. ... where when = '2006-09-06'::date.
> >
> >
> > I didn't understand you. Wha you mean '::date' ?
>
> This is a so called CAST. For example:
>
> test=# select now();
> now
> -------------------------------
> 2006-11-10 16:19:49.543082+01
> (1 row)
>
> test=# select now()::date;
> now
> ------------
> 2006-11-10
> (1 row)
>
>
> Read more about this:
> 16:23 < akretschmer> ??cast
> 16:23 < rtfm_please> For information about cast
> 16:23 < rtfm_please> see
> http://www.postgresql.org/docs/current/static/sql-createcast.html
> 16:23 < rtfm_please> or
> http://www.postgresql.org/docs/current/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS
>
>
> >
> > And if I have a period of time bigger than 1 day ?
>
> BETWEEN includes the boundaries, if you have full days so say something
> like 'between first_day and last_day'.
>
> Do you need time-boundaries? Rewrite your query to something like
> 'where time_column > time_1 and time_column < time_2'
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Atenciosamente (Sincerely)
Ezequias Rodrigues da Rocha
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
A pior das democracias ainda é melhor do que a melhor das ditaduras
The worst of democracies is still better than the better of dictatorships
http://ezequiasrocha.blogspot.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ezequias.rocha@gmail.com, andreas.kretschmer@schollglas.com
Subject: Re: Between and miliseconds (timestamps)
In-Reply-To: <55c095e90611101034r7dc6bf1btba72aa24f9300593@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox