Oracle DATE constant expression invariant to date format settings

$0
=
$0
+
$0
No specific Bitcoin Bounty has been announced by author. Still, anyone could send Bitcoin Tips to those who provide a good answer.
0

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

Tags: ,

1 Answer - total earned - 0 BTC ($0 USD)

1
=
0
=
$0
Everyone, even non-registered users could send Bitcoin Tips to YOU if they are inspired by your answer!

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;
SEND BITCOIN TIPS
1

Post Answer


Will Bitcoin Tipping become a new Internet Culture?


Please share our story! THANK YOU!