Obtain date from timestamp

♀尐吖头ヾ 提交于 2019-12-10 17:48:18

问题


I have a date field like this: 2017-03-22 11:09:55 (column name: install_date) I have another date field with date like this: 2017-04-20 (column name: test_date)

I would like to obtain only the date field from the above (2017-03-22) so that I can perform a DATEDIFF between install_date and test_date.


回答1:


Assuming you are looking for this in Hive, you can use TO_DATE function.

TO_DATE('2000-01-01 10:20:30') returns '2000-01-01'

NOTE: Input to TO_DATE is a string



来源:https://stackoverflow.com/questions/45291975/obtain-date-from-timestamp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!