I need to convert number to timestamp in PostgreSQL. I got numbers in database as character varying. I have seen there is a lot of solutions for integers but I got decimal numbers and here comes the issue.
The max I got is something like below using '1899-12-30'::DATE + CAST(Round(CAST(REPLACE(Excel_date_number, ',','.') as DOUBLE PRECISION)) as INTEGER)
| Value | Date |
|---|---|
| 45279,4029282407 | 2023-12-19 |
| 45294,5203472222 | 2024-01-04 |
| 45309,2083333333 | 2024-01-18 |
But I am completely lost in getting thw whole timestamp from these numbers. Can you give me any ideas how could I handle this?
Assuming you have the proper locale installed on your computer:
If you where to go this route I would suggest putting the above logic in a function and use that. It would make your queries a lot cleaner. The simpler solution per my comment would be to export the formatted datetime string from Excel not the underlying value. Lastly the above does not take into account timezone and just assumes you are working in the same timezone as that of Excel.