日時の減算

 2016/9/1 (木)    

#フィールド演算
str(datetime.datetime.now( ) - datetime.datetime.strptime( !Date1! , '%Y/%m/%d %H:%M:%S'))
 
import datetime
strDateTime = "2015/01/01 00:00:00"
before = datetime.datetime.strptime( strDateTime , '%Y/%m/%d %H:%M:%S')
print "前", before
now = datetime.datetime.now()
print "今", now
sa = now - before
print "差",sa,type(sa)

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.