1

I am stuck on a problem and I am not sure what is the best way to solve it. I have a date column that I want to select and I want to fetch it as a string. Which is great, node-oracledb module has this option with fetchAsString mehotd. But it fetches the date like this for example 10-JAN-16 and I want to fetch it like this 10-01-2016. Is there a way to do that from the node-oracledb module, or I should modify the date after I get the result from the query?

UPDATE: I mean solution without to_char in the query and without query modifications

2
  • In the select statement, you can use to_char function to change the format. Commented Sep 21, 2016 at 13:37
  • I am sorry @notionquest, I updated my question. I meant without using query modifications. Commented Sep 21, 2016 at 13:39

1 Answer 1

1

Check out this section of my series on Working with Dates in JavaScript, JSON, and Oracle Database: https://dzone.com/articles/working-with-dates-using-the-nodejs-driver

The logon trigger shows an example of using alter session to set the default date format. Keep in mind that there is NLS_DATE_FORMAT, NLS_TIMESTAMP_FORMAT, NLS_TIMESTAMP_TZ_FORMAT.

I only show NLS_TIMESTAMP_TZ_FORMAT because I convert to that type in the examples that follow as I need to do some time zone conversion for the date format I'm using.

Another way to set the NLS parameters is to use environment variables of the same name. Note that this method will not work unless you set the NLS_LANG environment variable as well.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, this is what I was looking for, thank you @Dan McGhan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.