Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

jdavidb
  (email not shown publicly)
http://voiceofjohn.blogspot.com/

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Thursday May 03, 2007
09:08 AM

Oracle hint for the clueless of the day: date conversions

[ #33187 ]

Example:

datevar2 := TO_DATE(TO_CHAR(datevar1, 'DD-Mon-YY HH24:MI:SS'), 'DD-Mon-YY HH24:MI:SS');

Hint: such conversions are never required. Hint 2: if you ever contemplate whether such a conversion is required, you probably don't belong in this business.

Hint 3: such conversions are not required even when date math is involved:

datevar2 := TO_DATE(TO_CHAR((datevar1 + 1/24), 'DD-Mon-YY HH24:MI:SS'), 'DD-Mon-YY HH24:MI:SS');

Taken from actual code, of course.

Oh, and hint 4: don't use such ugly date masks. Go with ISO standard or something: 'YYYY-MM-DD"T"HH24:MI:SS'. It's only internal anyway, right?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.