How to include a DATE constant / expression / literal in my PL/SQL script so the script would successfully run in different database environments with potentially different default date format settings? I am referring here to NLS settings, specifically NLS_DATE_FORMAT
I think the easiest is to use string literal encoding your date, together with the explicit date format to be used in conversion from your string to date
-- Dec 25, 2010
select to_date('20101225','YYYYMMDD') from dual;
-- DD means Day of month (1-31), so both statements below would produce Dec 1, 2010
-- note that MM does not have that ambiguity and must always be (01-12) with the LEADING ZERO
select to_date('20101201','YYYYMMDD') from dual;
select to_date('2010121','YYYYMMDD') from dual;
FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.
Boost your productivity with FavScripts.com!