User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Oracle Question Page [1]  
philihp
All American
8349 Posts
user info
edit post

Dear Oracle Programmers:

I came across this. Anyone have any idea why the author would have written it like this? I can only assume there is a reason. The author had to consciously write out this line, rather than just "startdate".

SELECT ...,
TO_DATE(TO_CHAR(starttime, 'DD-MON-YYYY HH:MI:SS'), 'DD-MON-YYYY HH:MI:SS'),
...
FROM sometable;

12/20/2010 5:23:03 PM

darkone
(\/) (;,,,;) (\/)
11611 Posts
user info
edit post

You're referring to this line, right?:
TO_DATE(TO_CHAR(starttime, 'DD-MON-YYYY HH:MI:SS'), 'DD-MON-YYYY HH:MI:SS')

TO_CHAR converts the non-character variable starttime to a character string with the given format. Then TO_DATE converts that character string with the specified format into a date variable.

12/20/2010 5:52:14 PM

KillaB
All American
1652 Posts
user info
edit post

My guess is, the database's default date format is different than what the person wanted to use, thus they used the combination of TO_CHAR TO_DATE to convert the default date format of starttime to the format they wished to use, DD-MON-YYYY HH:MI:SS.

As stated earlier though, this is only a guess.

12/21/2010 6:39:09 AM

Stimwalt
All American
15292 Posts
user info
edit post

^

this

12/21/2010 10:06:48 AM

 Message Boards » Tech Talk » Oracle Question Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.