How to convert sysdate to UTC time in oracle

11,069

Using CAST on the result of sys_extract_utc(systimestamp) is the solution to this since sys_extract_utc returns timestamp.

select cast(sys_extract_utc(systimestamp) as DATE) from dual;
Share:
11,069
Shubham Khatri
Author by

Shubham Khatri

I spend most of my free time answering questions on Stackoverflow and learning all the cool stuff thats out there. Follow me on Twitter for small Tips and Tricks and Checkout my articles on Medium. If you have any suggestions on what you would want me to write about, do DM me on twitter Some of my most useful answers: useState set method not reflecting change immediately ReactRouter v4 Prompt - override default alert Detect Route Change with react-router How to update the Context value in a Provider from the Consumer? Does new React Context API trigger re-renders? When to use functional setState Access React Context outside of render function Performing Authentication on Routes with react-router-v4 Handling async request with React, Redux and Axios? Unable to catch and log the Error response from an axios request How to pass params with history.push/Link/Redirect in react-router v4?

Updated on June 04, 2022

Comments

  • Shubham Khatri
    Shubham Khatri almost 2 years

    I am having a query to subtract a date from the sysdate. However the date object I have is in UTC but sysdate doesn't give me UTC time. How to I convert sysdate to give me date in UTC.

    I have already tried using sys_extract_utc

    select sys_extract_utc(systimestamp) from dual;
    

    This works fine and gives me the correct UTC time stamp. But the object returned by it is not the same as sysdate so when I subtract date from this object I get an INTERVAL DAY to SECOND but it should be a number.