0

I have a unix string. And want to display that in tableau date format which expects 5 arguments

import dataextract as tde
from datetime import datetime

tdefile=tde.Extract('USCSVExtract.tde')
tableDef.addColumn('CreationDate', tde.Type.DATE)

date_object = datetime.strptime(story.CreationDate, '%Y-%m-%d-%H:%M:%S.Z')
newrow.setDate(3,date_object)
table.insert(newrow)
tdefile.close()

value of story.CreationDate is 2014-10-31T20:02:36.622Z

I am unable to figure out T20:02:36.622Z this part

voraD
  • 515
  • 2
  • 5
  • 7

1 Answers1

1

You need to include the milliseconds part:

datetime.strptime(string, '%Y-%m-%dT%H:%M:%S.%fZ')
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Batman
  • 8,571
  • 7
  • 41
  • 80
  • 1
    *whispers* and also the `T` character – R Nar Nov 16 '15 at 20:54
  • And also the `T` character. – Batman Nov 16 '15 at 20:55
  • Still it is giving error- TypeError: setDate() takes exactly 5 arguments (3 given) – voraD Nov 16 '15 at 21:41
  • newrow.setDate(3,datetime.strptime(story.CreationDate, '%Y-%m-%dT%H:%M:%S.%fZ')) – voraD Nov 16 '15 at 21:42
  • What does the method signature look like? My guess is that you don't want to pass it a `datetime` object, but the year, month, and day integers. I.e. `newrow.setDate(3, date_object.year, date_object.month, date_object.day)` – Batman Nov 16 '15 at 21:49