1

I used to have this code in Visual Basic:

rpt.ParameterFields.GetItemByName("RowDate").AddCurrentValue CDate("2010-03-19")

and I cannot figure out into what I have to convert date to make eatable for COM.

Any suggestions?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • Could you describe what it should do with the `"2010-03-19"` string? – eumiro Oct 19 '10 at 14:17
  • Eumiro, It shoould convert date string into COM date representation in the same way like CDate does... BTW found answer. –  Oct 19 '10 at 14:20

1 Answers1

2

Ok, found solution. Bellow is python equivalent:

rpt.ParameterFields.GetItemByName("RowDate").AddCurrentValue(datetime.datetime.strptime('2010-03-19', "%Y-%m-%d").date())

Approach is the same like in: Python date string to date object

Community
  • 1
  • 1
  • Thanks. I was looking at the same issue having a VBS sample of a COM interaction and migrating it to Python. I will add that I find `dateutil.parser.parse` much nicer for converting text to datetime as it does not stipulate a format string (works by inference and is right most of the time). – Bernd Wechner Nov 10 '22 at 02:15