View previous topic :: View next topic
|
Author |
Message |
liying
New User
Joined: 27 May 2010 Posts: 47 Location: da lian.china
|
|
|
|
I want to format DATE field use sql
data in table:
Object_date
2015/01/01
2015/01/02
2015/01/03
Result I want by SQL SELECT:
Result_date
2015-01-01
2015-01-02
2015-01-03
Both the attribute is CHAR(10). Is there any way without use complicate function like YEAR(Object_date) ||'-'||Month(Object_date)||'-'||Day(Object_date)? |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
I have already recommended the use of the VARCHAR_FORMAT function,
however I read somewhere that in some versions of SQL it works only with TIMESTAMP, not DATE.
You'll have to try and tell us. |
|
Back to top |
|
|
liying
New User
Joined: 27 May 2010 Posts: 47 Location: da lian.china
|
|
|
|
Marso wrote: |
I have already recommended the use of the VARCHAR_FORMAT function,
however I read somewhere that in some versions of SQL it works only with TIMESTAMP, not DATE.
You'll have to try and tell us. |
Thank you for your reply.
VARCHAR_FORMAT do not work with DATE type filed format. I have find the way like this .
SELECT REPLACE(START_DATE,'/','-') FROM tabl1
FETCH FIRST 100 ROWS ONLY
And my problem have been solved. Thank again for your attention. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
solution to this have been already discussed multiple times on this forum before even you post such questions should have checked to reduce the duplicates. |
|
Back to top |
|
|
|