0

I am using Adminer 4.7.3 connecting to an oracle DB and I want to display dates in a different format from what the default is ('DD-MON-YY'). I tried using the command ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH:MI:SS' but it only lasts for that query, and it goes back to the old date format once I open the table again. Is there a better way to force the date to show up in a different format?

yunyun333
  • 131
  • 1
  • 7

1 Answers1

1

You have a few options. First, you can perform an

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH:MI:SS'

every time you log on. If you don't want to do this you can:

  1. If you're using *nix:

    setenv NLS_DATE_FORMAT "dd-mon-yyyy hh:mi:ss"

  2. If you're using Windows:

    Control Panel-System-Advanced System Settings-Environment Variables, and create the NLS_DATE_FORMAT environment variable with the appropriate setting.

  3. If you want an entirely database-dependent solution, you can use an ON LOGON trigger similar to the following:

    CREATE OR REPLACE TRIGGER DATABASE_AFTER_LOGON AFTER LOGON ON DATABASE BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT = ''DD-MON-YYYY HH:MI:SS'''; END DATABASE_AFTER_LOGON;

  • I tried doing the first thing, but it doesn't "last"; with Adminer, I can enter the command and then enter another query, like 'ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH:MI:SS; SELECT * FROM dates_table' and it will work, but then if I enter another query, it will show the dates in the default format. – yunyun333 Oct 10 '19 at 19:03