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