From: Scott Ribe <scott_ribe@elevated-dev.com>
To: M Sarwar <sarwarmd02@outlook.com>
Cc: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: Re: Conversion from Number to Date
Date: Thu, 15 Jun 2023 20:29:59 -0600
Message-ID: <3C2586BD-E0DC-4BAB-B791-1A789BAFFB7E@elevated-dev.com> (raw)
In-Reply-To: <PH7PR19MB59686176B5B56B8FE3876939D358A@PH7PR19MB5968.namprd19.prod.outlook.com>
References: <PH2P110MB0922CF0FC2F018080EF7A41DFF58A@PH2P110MB0922.NAMP110.PROD.OUTLOOK.COM>
<PH7PR19MB59686176B5B56B8FE3876939D358A@PH7PR19MB5968.namprd19.prod.outlook.com>
> On Jun 15, 2023, at 8:23 PM, M Sarwar <sarwarmd02@outlook.com> wrote:
>
> During the data load from CSV files to the database, the above START_TIME and STOP_TIME date column data arrived as number value.
> Now I need to translate the START_TIME and STOP_TIME back to DATE format.
Add a number to a date, you get a date that many days out. Similarly, you can add an interval to a timestamp. So you'll need to know the base used for those numbers, and the unit of measurement.
For instance, if the numbers for date are an offset from 1970-01-01 (Unix epoch):
'1970-01-01'::date + <number>
If the numbers for time are seconds from then:
'1970-01-01'::timestamptz + '<number> seconds'::interval
Of course you'll also need to know what time zone the times are in, I will graciously leave that as an exercise ;-)
Also, the documentation page you needed:
https://www.postgresql.org/docs/15/functions-datetime.html
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-admin@postgresql.org
Cc: scott_ribe@elevated-dev.com, sarwarmd02@outlook.com, pgsql-admin@lists.postgresql.org
Subject: Re: Conversion from Number to Date
In-Reply-To: <3C2586BD-E0DC-4BAB-B791-1A789BAFFB7E@elevated-dev.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