pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Rick Dearman <rick@ricken.demon.co.uk>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [GENERAL] Returning an integer from a date
Date: Tue, 30 Mar 1999 13:51:16 +0200
Message-ID: <l03110709b32669184aa5@[147.233.148.140]> (raw)
In-Reply-To: <36FFE017.9E1F65A2@ricken.demon.co.uk>
References: <l03110705b325274430ee@[147.233.148.145]>

At 22:18 +0200 on 29/03/1999, Rick Dearman wrote:


>
> I want the number  of seconds since 1970

Basically, the function date_part( 'epoch', expression_of_datetime_type )
returns the number of seconds since 1970. But it returns a float, not an
integer, because datetimes can include milliseconds etc.

For example:

testing=> select date_part( 'epoch' , '1999-03-01 07:38:01.10'::datetime);
  date_part
-----------
920266681.1
(1 row)

So, you may either write your program to expect a float there (float8), or
you can force it to be an integer using the function int() around the
date_part function. But then you lose the milliseconds.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (4+ messages)

Message-ID: <l03110709b32669184aa5@[147.233.148.140]>
Permalink:  ../l03110709b32669184aa5@%5B147.233.148.140%5D/
Also on:    postgresql.org/message-id/l03110709b32669184aa5@[147.233.148.140]

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, rick@ricken.demon.co.uk
  Subject: Re: [GENERAL] Returning an integer from a date
  In-Reply-To: <l03110709b32669184aa5@[147.233.148.140]>
  References: <l03110705b325274430ee@[147.233.148.145]> <l03110709b32669184aa5@[147.233.148.140]>

* 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