从时间戳获取日期 [英] Obtain date from timestamp

查看:117
本文介绍了从时间戳获取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的日期字段:2017-03-22 11:09:55(列名:install_date) 我还有另一个日期字段,其日期是这样的:2017-04-20(列名:test_date)

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)

我只想从上述(2017-03-22)中获取日期字段,以便可以在install_date和test_date之间执行DATEDIFF.

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.

推荐答案

假设您正在Hive中寻找它,则可以使用TO_DATE函数.

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:输入TO_DATE是一个字符串

NOTE: Input to TO_DATE is a string

这篇关于从时间戳获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆