简体   繁体   English

将每小时时间戳从 GMT 转换为 PDT 的问题

[英]Issues with converting the hourly timestamp from GMT to PDT

I'm looking for answers to the below query.我正在寻找以下查询的答案。

   select count(1), to_char(DATE_CREATED,'DD-MM-YYYY HH24') from GDPR where DATE_CREATED>sysdate-1
    group by to_char(DATE_CREATED,'DD-MM-YYYY HH24') order by to_char(DATE_CREATED,'DD-MM-YYYY HH24');

  COUNT(1) TO_CHAR(DATE_
---------- -------------
         4 22-07-2020 02
        32 22-07-2020 03
        33 22-07-2020 09
         7 22-07-2020 14
        26 22-07-2020 15

Here the hour field(02,03....) that I'm getting is in GMT.这里我得到的小时字段(02,03 ....)是格林威治标准时间。 I wanted it in PDT.我想要它在 PDT 中。 I tried to cast it in new_time function but it's getting erred out as invalid month.我试图将它转换为 new_time function 但它被误认为是无效月份。 Not sure what's the issue.不确定是什么问题。 Any help will be appreciated.任何帮助将不胜感激。 Thank you.谢谢你。

From GMT to PDT you can use new_time.从 GMT 到 PDT,您可以使用 new_time。 ie IE

SELECT date_created, new_time(date_created, 'GMT', 'PDT') FROM gdpr;

Make sure, that date_created is of datatype DATE.确保 date_created 的数据类型为 DATE。

To cut minutes/seconds and convert to vc2, use the to_char function with the result of new_time(), ie to_char(new_time(date_created, 'GMT', 'PDT'), 'DD.MM.YYYY HH24')要减少分钟/秒并转换为 vc2,请使用带有 new_time() 的结果的 to_char function,即to_char(new_time(date_created, 'GMT', 'PDT'), 'DD.MM.YYYY HH24')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM