spark 中时间和日期 操作,怎么找到前几天后几天
1. timestamp 增加减少一个 time delta
df.withColumn("added_hours",col("input_timestamp") + expr("INTERVAL 2 HOURS"))
.withColumn("added_minutes",col("input_timestamp") + expr("INTERVAL 2 minutes"))
.withColumn("added_seconds",col("input_timestamp") + expr("INTERVAL 2 seconds"))
.show(false)
+-----------------------+-----------------------+-----------------------+-----------------------+
|input_timestamp |added_hours |added_minutes |added_seconds |
+-----------------------+-----------------------+-----------------------+-----------------------+
|2019-07-01 12:01:19.101|2019-07-01 14:01:19.101|2019-07-01 12:06:19.101|2019-07-01 12:02:14.101|
|2019-06-24 12:01:19.222|2019-06-24 14:01:19.222|2019-06-24 12:06:19.222|2019-06-24 12:02:14.222|
|2019-11-16 16:44:55.406|2019-11-16 18:44:55.406|2019-11-16 16:49:55.406|2019-11-16 16:45: