Skip to main content

TO_DATE(SYSDATE) used on a DATE value - is this intended?

  • Dec 1, 2026 11:51 AM UTC
  • 1 reply
  • 17 views

Forum|alt.badge.img+17

In many places in IFS Clooud codeI found the construct TO_DATE(SYSDATE)

(and TO_DATE(SYSDATE - n)) applied directly to a DATE value.

The Oracle SQL Language Reference states in the Purpose section of TO_DATE

that TO_DATE must not be used with a DATE value as the char argument,

because the returned value may differ from the original depending on the

format model or the session's default date format.

Our concern is that this makes the expression NLS-dependent:

- the DATE is implicitly converted to a string using NLS_DATE_FORMAT,

then parsed back,

- with a date-only session format the time component is lost, so a

predicate such as "col BETWEEN TO_DATE(SYSDATE-1) AND TO_DATE(SYSDATE)"

silently returns a different row set depending on the client session,

- with a format model that omits the day (e.g. 'MM/YYYY'), the resulting

value is the first day of the current month.

Questions:

1. Is TO_DATE(SYSDATE) here intentional, and if so, what is the intended

semantics?

2. If a truncation to midnight is intended, can it be replaced by

TRUNC(SYSDATE), which is NLS-independent?

3. Is the behaviour of this code guaranteed for sessions running with a

non-default NLS_DATE_FORMAT / NLS_TERRITORY?

1 reply

PhillBronson
Hero (Customer)
Forum|alt.badge.img+13
  • Hero (Customer)
  • Dec 2, 2026 9:10 PM UTC

​@knepiosko good question, I also thought that was suspicious. Hopefully, some extra traffic will get this question answered.