## Summary When using the `pg` library and connecting to an EnterpriseDB server, fields with the `timestamp without time zone`[^1] [datatype-datetime](https://www.postgresql.org/docs/16/datatype-datetime.html) type would return `null` values. This is caused by the server returning the timestamp in a format that the Node.JS driver cannot convert to a `Date` object. The current [solution](#solution) is to direct the driver to parse the timestamp as a string instead. ## Behavior When attempting to query an [EnterpriseDB](https://www.enterprisedb.com) (EDB) (EPAS v16.5) database, using the [pg](https://github.com/brianc/node-postgres) Node.JS package, values in columns with the `timestamp without time zone` [datatype-datetime](https://www.postgresql.org/docs/16/datatype-datetime.html) return `null`. This issue causes the application to not display accurate data in a table by showing blank dates. ## Research As the EDB Database was a new addition to the stack, the initial reaction was to validate that all the data had successfully migrated over from Community Postgres. Once validation of all data was complete the investigation was turned towards the code itself. Some recent changes had been made to how dates were displayed on the pages so to ensure these updates were not the cause, we first pointed the application towards the legacy database. When pointing at the legacy database, dates were returned normally, switching back to EDB, dates became `null` once again. We reached out to one of our contacts at EnterpriseDB to see if they had seen this behavior before, and if they could provide any assistance. While waiting for a reply we began independent 'research' leading us to an issue posted on the [pg](https://github.com/brianc/node-postgres) package's GitHub account. [Wrong Timestamp!](https://github.com/brianc/node-postgres/issues/429#issuecomment-24870258) This issue gave a solution that ultimately worked in resolving the issue. Shortly after finding this solution, our contact at EDB reached back out and had referenced this issue, [Driver returns null instead of date](https://github.com/brianc/node-postgres/issues/471), posted to the same repository. You can find these solutions below. ## Solution ^9ed550 Add the following code in your db connector file.[^2] ```js var types = require('pg').types; var timestampOID = 1114; types.setTypeParser(1114, function(stringValue) { return stringValue; }) ``` Another example showed this as a possible solution[^3]: ```js var types = require('pg').types types.setTypeParser(1082, String) types.setTypeParser(1114, String) types.setTypeParser(1184, String) ``` # References [^1]: [Postgres Reference - Date/Time](https://www.postgresql.org/docs/current/datatype-datetime.html)*postgresql.org* Retrieved November 21, 2024 [^2]: [GitHub Issue](https://github.com/brianc/node-postgres/issues/429#issuecomment-24870258) *github.com* Retrieved November 21, 2024 [^3]: [GitHub Issue](https://github.com/brianc/node-postgres/issues/471) *github.com* Retrieved November 21, 2024