我的表有一个类型为integer的date列
当我这样做的时候:
sc.sql('select date from table).show(1)我得到了:
19860102但是如果我运行:
sc.sql('select cast(date to Timestamp) from table).show(1)我得到了:
1970-08-18 20:41:42如何将此df日期字段从Integer转换为string以使用dayofweek函数?
有没有办法用sql代替函数F呢?
发布于 2021-12-01 06:01:33
您可以通过一些字符串格式化和一些数学运算来实现这一点。
select format_string('%d-%02d-%02d', floor(date / 10000), floor(date / 100) % 100, date % 100) from tablehttps://stackoverflow.com/questions/70179624
复制相似问题