I'm trying to convert datetime column to ISO datetime format without any success.
The only correct result I managed to get is by doing this sql:
select TO_CHAR(getdate(), 'YYYY-MM-DD')||'T'||TO_CHAR(getdate(),'HH24:MI:SS')
but I'm sure there is a more adequate method to achieve this.
Just to make sure I'm clear enough, I'm trying to get this format: 2011-12-03T10:15:30
P.S.
I tried the trivial sql and it doesn't work ==>
SELECT TO_CHAR(getdate(), 'YYYY-MM-DDTHH24:MI:SS');
gives this result:
2017-02-19THH24:38:46
and of course I wanted it differently: 2017-02-19T10:38:46
OK, I managed to achieve this with the mix of ' and " ==>
SELECT TO_CHAR(getdate(), 'YYYY-MM-DD"T"HH24:MI:SS');
gives the result of: 2017-02-19T16:00:40
EDIT: I found a simpler solution:
SELECT TO_CHAR(getdate(), 'YYYY-MM-DDThh24:MI:SS');
It appears that the upper HH made a problem. Once converted to hh it worked
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With