Re: Conversion from Number to Date - Mailing list pgsql-admin

From Scott Ribe
Subject Re: Conversion from Number to Date
Date
Msg-id 3C2586BD-E0DC-4BAB-B791-1A789BAFFB7E@elevated-dev.com
Whole thread Raw
In response to Conversion from Number to Date  (M Sarwar <sarwarmd02@outlook.com>)
Responses Re: Conversion from Number to Date
List pgsql-admin
> 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
numbervalue. 
> 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
needto 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




pgsql-admin by date:

Previous
From: M Sarwar
Date:
Subject: Conversion from Number to Date
Next
From: Ron
Date:
Subject: Re: Conversion from Number to Date