date format [message #678358] |
Wed, 27 November 2019 11:53  |
 |
kabina
Messages: 8 Registered: November 2019
|
Junior Member |
|
|
I am new to Oracle SQL , I know SQL how it works. Syntax are bit different than SQL server . I build reports in companies. I need to pull some data from oracle database.
I want know , I have field POCREATED_DATE datatype date
when I use select query to get this date it gives me 01-FEB-17 but I want in this format 02/01/2016 2:21:00 PM , I want my data type remain same.
Thanks in advance.
|
|
|
|
|
Re: date format [message #678373 is a reply to message #678358] |
Thu, 28 November 2019 01:27   |
John Watson
Messages: 8977 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
Perhaps Oracle is a bit more versatile than SQL Server? For example (and please note the use of code tags),orclz> select
2 sysdate session_default,
3 to_char(sysdate,'dd-MON-yyyy') typical_us,
4 to_char(sysdate,'dd Month year','nls_date_language=Czech') more_variations
5 from dual;
SESSION_DEFAULT TYPICAL_US MORE_VARIATIONS
------------------- -------------------- ------------------------------------------------------------------------------
2019-11-28:07:27:19 28-NOV-2019 28 Listopad twenty nineteen
orclz>
|
|
|
Re: date format [message #678389 is a reply to message #678373] |
Fri, 29 November 2019 07:39   |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
The second argument is the format mask. All you need to do if you want it to use the default for your workstation simply use
select to_char(POCREATED_DATE,'MM/DD/YYYY HH:MI:SS AM') FROM TABLE_NAME;
|
|
|
Re: date format [message #678393 is a reply to message #678389] |
Fri, 29 November 2019 09:13   |
cookiemonster
Messages: 13967 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
We tend to say that, but to be honest - if you're talking about an application querying dates it's usually best to set the session nls_date_format, so every can get their preferred format and you don't have to write to_char all the time.
|
|
|
|