如何连接 Date 字段和 Float 字段以获得 DateTime 字段?

How can I concat Date field and Float one to get a DateTime field?

T2 = fields.Float()
date = fields.Date()

例如如果 T2= 09:00 和日期 =12/09/2017

结果应该是 12/09/2017 09:00

您可以将 T2 转换为 str 并将两者组合在一起

  T2= "09,00"
  date = datetime.date(2017,9,12)
  date_str = date.strftime('%d/%m/%Y')
  print date_str
  date_str += T2
  print date_str
  print datetime.datetime.strptime(date_str, '%d/%m/%Y%H,%M')


12/09/2017
12/09/201709,00
2017-09-12 09:00:00

或者如果t2是float类型

  T2= 8.5
  date = datetime.date(2017,9,12)
  print datetime.datetime.fromordinal(date.toordinal()) + datetime.timedelta(seconds=T2*3600)

2017-09-12 08:30:00