number to date format ? [message #621169] |
Mon, 11 August 2014 01:03 |
tondapi
Messages: 99 Registered: August 2007 Location: usa
|
Member |
|
|
Hi,
In my table 'calender', I have a column called 'Year_Mon_value' and data is like '201404,201405,2014,06,201407...etc').
How to bring my query to display the data in below format.
2014 Apr
2014 Jun
2014 Jul....
Note : Year_mon_value is number formate
Thanks,
|
|
|
|
Re: number to date format ? [message #621171 is a reply to message #621169] |
Mon, 11 August 2014 01:08 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
It is a bad practise to have a date column as number type. The permanent solution is to change the data type.
In your case, convert the number to char, then use to date, then to char and use proper date format mask to achieve the desired output.
Edit : And never rely on implicit data type conversions.
[Updated on: Mon, 11 August 2014 01:10] Report message to a moderator
|
|
|
Re: number to date format ? [message #621172 is a reply to message #621171] |
Mon, 11 August 2014 01:13 |
tondapi
Messages: 99 Registered: August 2007 Location: usa
|
Member |
|
|
Littlefoot thanks !, It is working fine.
Lalit Kumar B : Request the developer team to change the number type to data type.Due to some reason it is not possibale.
|
|
|
Re: number to date format ? [message #621187 is a reply to message #621172] |
Mon, 11 August 2014 07:56 |
|
EdStevens
Messages: 1376 Registered: September 2013
|
Senior Member |
|
|
tondapi wrote on Mon, 11 August 2014 01:13Littlefoot thanks !, It is working fine.
Lalit Kumar B : Request the developer team to change the number type to data type.Due to some reason it is not possibale.
It is possible.
But it won't be easy, since the app is already developed to a bad data model.
The limitation isn't technical, but managerial.
[Updated on: Mon, 11 August 2014 07:57] Report message to a moderator
|
|
|
Re: number to date format ? [message #621188 is a reply to message #621187] |
Mon, 11 August 2014 08:18 |
ThomasG
Messages: 3211 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
EdStevens wrote on Mon, 11 August 2014 14:56The limitation isn't technical, but managerial.
It MIGHT be a technical reason, if one of the goals of the applications is to be as database agnostic as possible. Date types tend to be more different in their implementations across different databases than number or char types.
IF that was the reason a number type was chosen to represent a date than care has to be taken the "workarounds" doesn't negate that goal. So I wouldn't accept "some reason" from the dev team, the specific reason might be important to know for anybody who is working with the system.
|
|
|
|
|
|
Re: number to date format ? [message #621212 is a reply to message #621207] |
Mon, 11 August 2014 12:24 |
|
EdStevens
Messages: 1376 Registered: September 2013
|
Senior Member |
|
|
Michael/Lalit,
And how does oracle itself achieve "OS neutrality"? Isn't it by isolating OS-specific stuff to behind a procedure or even lower-level API call? Exactly as I maintain that a 'db-neutral' application should do? And as many other DBAs advocate that all access to tables should be via a package? Of course even the syntax of calling a procedure could vary between various vendors dialects of SQL.
Hmm. What does TK say about database neutrality?
"With the exception of some read-only applications, it is my contention that building a wholly database-independent application that is highly scalable is extremely hard - and is in fact quite impossible unless you know exactly how each database works in great detail." (Thomas Kyte, "Expert one-on-one Oracle", c. 2001, Wrox, pg 37).
I'd go one step further. Given his comment about "impossible unless ..." (emphasis mine), how many developers really have a detailed knowledge of how even one database product works, at the level to which Mr. Kyte refers? Much less multiple database products. And even being generous about that, given the fundamental differences in how different products handle locking and transaction control, I don't know if any level of expertise could product such an application.
Just a one-off personal observation .. I once attended a pitch for an app where the vendor claimed that their product would run on any database, but they recommended SQL Server because they "found that oracle cannot sustain more than five concurrent connections."
Of course we don't know that the OP supporting a commercial app that is trying to be database neutral. I'd actually rather hazard a guess that he's not, and his developer's use of a NUMBER to store a DATE is just one more example of the all-too-common practice of poor data typing.
|
|
|
Re: number to date format ? [message #621213 is a reply to message #621212] |
Mon, 11 August 2014 12:42 |
|
Michel Cadot
Messages: 68645 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
I didn't advocate for any database neutrality implementation, my remark was just to emphasize the question is not in the scope of the database. If you declare something as a number then it is a number for the database despite what you think it is.
I always said that an application is developed for one rdbms and can't be for several ones, first for locking, transactional reasons and then for performances ones.
I always said that implementing a date as a number or a string is not only stupid it is a lack of the basic of relational theory which states that attributes have a type (which implies possible operations on it) and a range of values.
Edit: so, in short, we are in agreement.
[Updated on: Mon, 11 August 2014 12:43] Report message to a moderator
|
|
|
|
|