Skip site navigation (1) Skip section navigation (2)

Conversion from Unix timestamp to datetime?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-sql(at)postgresql(dot)org
Subject: Conversion from Unix timestamp to datetime?
Date: 1998-07-13 19:21:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
I'd like to be able to convert between times specified in Unix timestamp
format and SQL datetime values without going through the slow and rather
error-prone process of converting to a human-readable date notation.

I see how to get a datetime value returned as a Unix timestamp:
	tgl=> select date_part('epoch', 'now'::datetime);
	(1 row)

But I don't see any way to supply a value in the form "900355156"
and have it get converted to datetime.  Is there a way to do that?

BTW, it seems like the standard data type 'timestamp' ought to be
good for this, but it isn't as far as I can tell ... it hasn't got
any working conversions to/from integer either.

			regards, tom lane


pgsql-sql by date

Next:From: Dan DelaneyDate: 1998-07-13 20:02:27
Subject: How do I store graphics in my tables?
Previous:From: Guido PiazziDate: 1998-07-13 17:26:09
Subject: Re: [SQL] empty data

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group