I have some tables in a postgres that have a column for year and a column for quarter (both stored as bigint). I need to be able to combine those together in the output of a query in the form of 'YYYYQ' (not the hard part) AND have the datatype of that field be datetime (<--the hard part).
The only query I have attempted that didn't fail was -
SELECT to_date((year::VARCHAR + quarter::VARCHAR),'YYYYQ') AS Stuff
FROM company.products
And while the output is in DATETIME format, there is no Quarter info in it.
Sample -
| stuff |
|---|
| 2011-01-01 |
| 2011-01-01 |
| 2012-01-01 |
| 2012-01-01 |
| 2012-01-01 |
Is it even possible to create output that has the format 'YYYYQ' AND is in DATETIME format? And if so, how?