Reputation: 329
I have a date column in this format "03-FEB-16" in a database table. I want to query the database to get UTC format equivalent of that date value:
This is the UTC format I am looking for "2015-12-17T14:30:33Z"
Upvotes: 1
Views: 17605
Reputation: 329
I think I found my answer but Please feel free to post alternative ways to do it.
The following query did the trick:
select to_char(sysdate,'YYYY-MM-DD')||'T'||to_char(sysdate,'HH24:MI:SS')||'Z' from dual
Upvotes: 0
Reputation: 21
Try this:
SELECT TO_CHAR(cast(SYSDATE as timestamp) at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"') FROM DUAL
Change SYSDATE to say SYSDATE-150 to test different times of the year
Upvotes: 2