简体   繁体   中英

problem with transformation to_timestamp python sql on databricks

I am trying to implement a transformation in python sql on databricks, I have tried several ways but without success, I request a validation please:

%sql
 SELECT aa.AccountID__c as AccountID__c_2,
  aa.LastModifiedDate,
  to_timestamp(aa.LastModifiedDate, "yyyy-MM-dd HH:mm:ss.SSS") as test
  FROM EVENTS aa

The output is as follows:

在此处输入图像描述

It can be seen that the validation is not correct, but even so it is executed on the engine and returns null.

I have also tried performing a substring on the LastModifiedDate field from 1 to 19, but without success...

The date format you provided does not agree with the date format of that column, so you got null. Having said that, for standard date formats like the format you have, there is no need to provide any date format at all. Simply using to_timestamp will give the correct results.

%sql
SELECT aa.AccountID__c as AccountID__c_2,
  aa.LastModifiedDate,
  to_timestamp(aa.LastModifiedDate) as test
FROM EVENTS aa

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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