spark日期处理

本文详细介绍了SQL中处理日期和时间的各种方法,包括获取当前时间、从日期时间中提取字段、日期时间转换以及进行日期时间计算。通过实例展示了如何使用如current_date、current_timestamp、year、month、day、unix_timestamp、from_unixtime、add_months、last_day等函数。

详情查看:https://www.cnblogs.com/feiyumo/p/8760846.html

以防止文章丢失,我搬运过来。 !!!转载自飞末!!!

一、获取当前时间

1.current_date获取当前日期

2018-04-09

2.current_timestamp/now()获取当前时间

2018-04-09 15:20:49.247

二、从日期时间中提取字段 

1.year,month,day/dayofmonth,hour,minute,second

Examples:> SELECT day('2009-07-30'); 30

2.dayofweek (1 = Sunday, 2 = Monday, ..., 7 = Saturday),dayofyear

Examples:> SELECT dayofweek('2009-07-30');   5

Since: 2.3.0

3.weekofyear

weekofyear(date) - Returns the week of the year of the given date. A week is considered to start on a Monday and week 1 is the first week with >3 days.

Examples:> SELECT weekofyear('2008-02-20');   8

6.date_format将时间转化为某种格式的字符串

Examples:> SELECT date_format('2016-04-08', 'y');    2016

三、日期时间转换

1.unix_timestamp返回当前时间的unix时间戳

Examples:

> SELECT unix_timestamp();  1476884637
> SELECT unix_timestamp('2016-04-08', 'yyyy-MM-dd');   1460041200

2.from_unixtime将时间戳换算成当前时间,to_unix_timestamp将时间转化为时间戳

Examples:

> SELECT from_unixtime(0, 'yyyy-MM-dd HH:mm:ss');  1970-01-01 00:00:00
>SELECT to_unix_timestamp('2016-04-08', 'yyyy-MM-dd');  1460041200

3.to_date/date将字符串转化为日期格式,to_timestamp(Since: 2.2.0)

> SELECT to_date('2009-07-30 04:17:52');  2009-07-30
> SELECT to_date('2016-12-31', 'yyyy-MM-dd');   2016-12-31
> SELECT to_timestamp('2016-12-31 00:12:00');   2016-12-31 00:12:00

4.quarter 将1年4等分(range 1 to 4)

Examples:> SELECT quarter('2016-08-31');  3

四、日期、时间计算

1.months_between两个日期之间的月数

months_between(timestamp1, timestamp2) - Returns number of months between timestamp1 and timestamp2.

Examples:> SELECT months_between('1997-02-28 10:30:00', '1996-10-30');  3.94959677

2. add_months返回日期后n个月后的日期

Examples:> SELECT add_months('2016-08-31', 1);  2016-09-30

3.last_day(date),next_day(start_date, day_of_week)

Examples:

> SELECT last_day('2009-01-12');  2009-01-31
> SELECT next_day('2015-01-14', 'TU');  2015-01-20

4.date_add,date_sub(减)

date_add(start_date, num_days) - Returns the date that is num_days after start_date.

Examples:

> SELECT date_add('2016-07-30', 1);  2016-07-31

5.datediff(两个日期间的天数)

datediff(endDate, startDate) - Returns the number of days from startDate to endDate.

Examples:> SELECT datediff('2009-07-31', '2009-07-30'); 1

 

 

为了查找与测绘遥感相关的SCI期刊列表,可以通过学术搜索引擎或访问特定的数据库来获得最新的信息。通常这些资源会定期更新以反映最新收录情况。 些常用的搜索方式包括: 查阅Web of Science (WOS) 数据库 这是最直接的方法之,因为Science Citation Index(SCI)正是由该数据库维护。可以在其中设置关键词为"remote sensing", "surveying and mapping" 或者更具体的主题术语,并选择仅显示被SCI索引的文章和期刊。 利用Google Scholar 虽然不是专门针对SCI期刊,但可以找到很多高影响力的测绘遥感类文章及其发表刊物的信息。从这里也可以了解到哪些是活跃且受认可的研究领域内的出版物。 参考Journal Citation Reports (JCR) 这是个评估科学和技术期刊影响力的重要工具。通过查看影响因子和其他指标,可以帮助确定哪些测绘遥感领域的期刊最具权威性并且属于SCI范畴。 咨询图书馆员或专业人士 大学或研究机构的专业人员能够提供指导和支持,帮助定位最适合需求的具体期刊名称及详情。 订阅行业通讯和服务 某些服务如Elsevier's Scopus也会报告关于各个学科顶级期刊的消息,保持关注可以获得及时的通知。 以下是几个知名的测绘遥感相关SCI期刊的例子: - Remote Sensing of Environment - IEEE Transactions on Geoscience and Remote Sensing - ISPRS Journal of Photogrammetry and Remote Sensing - International Journal of Applied Earth Observation and Geoinformation 请注意,实际的SCI期刊名单可能会随着时间而变化,因此建议总是使用最新的在线资源来进行确认。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值