snowflake-connector-nodejs
snowflake-connector-nodejs copied to clipboard
SNOW-616705: Date.toJSON() doesn't return expected date string
Please answer these questions before submitting your issue. Thanks!
- What version of NodeJS are you using (
node --version
andnpm --version
)?
v14.17.5
- What operating system and processor architecture are you using?
System Version: macOS 12.4 (21F79) Kernel Version: Darwin 21.5.0
- What are the component versions in the environment (
npm list
)?
"snowflake-sdk": "^1.6.4",
- What did you do?
Fetch data from snowflake where there is a column of type TIMESTAMP_NTZ(9). The values for that column are of type Date but the method toJSON() doesn't return the expected value.
- What did you expect to see?
value.toJSON(); // returns "2017-02-11T03:00:00.000Z"
- What did you see instead?
value.toJSON(); // returns "2017-02-11 03:00:00.000"
Hi @ZeRego , Snowflake timestamp has many different output formats as stated https://docs.snowflake.com/en/user-guide/date-time-input-output.html#timestamp-formats. I think the one you saw is just one of them. And I was wondering maybe use different timestamp output format can help. Have you tried this was before?
@sfc-gh-wshangguan thank you for the docs, I didn't know about that.
The parameters can be set at the account, user, and session levels.
For context, our user adds their snowflake credentials in our application and we then execute sql against it. So we have no control over their format settings.
Is it possible to set the desired format when create a connection, via ConnectionOptions
or when we execute sql ?
Our current workaround is basically new Date(dateValueFromSnowflake).toJSON()
which gives us the expected string.
Hi @ZeRego ,
Is it possible to set the desired format when create a connection, via ConnectionOptions or when we execute sql ?
So your application manages the connection (or we call it a session) for users? If so, it seems like altering the parameter at session level can be an option. The setting of a parameter at session level only lives within this single connection. Once the connection is closed, the settings just go away. And it won't impact any other level settings of the users.
hi @ZeRego been reviewing some issues and stumbled across this one. seems there's been already an answer. do you think this issue can be closed or do you require any further assistance with it ?
closing this issue for now, but please reopen if you still need help