python 中hive 取日期时间的方法

Posted 静悟生慧

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 中hive 取日期时间的方法相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env python3
import sys
import os
import time, datetime

sys.path.append(os.getenv(‘HIVE_TASK‘))
from HiveTask import HiveTask
ht = HiveTask()

day_dt = ht.data_day_str
buy_begin = ht.oneday(-80)
buy_end = ht.oneday(-20)
day_begin = ht.oneday(-5)
day_end = ht.oneday(0)

print (day_dt)
print (buy_begin)
print (buy_end)
print (day_begin)
print (day_end)

print (‘ok‘)

  打印结果:

2018-11-20
2018-09-01
2018-10-31
2018-11-15
2018-11-20

以上是关于python 中hive 取日期时间的方法的主要内容,如果未能解决你的问题,请参考以下文章