create date time from string

1
I am trying to create a datetime from a string. I've tried dateTime(parseInteger($Month),parseInteger($Day),parseInteger($Year)) and get a message that dateTime needs literal integers. I've also tried parseDateTime($Month + '-' + $Day + '-' + $Year,'MM-dd-yyyy') where $Month = 'January', $Day = '1' and $Year = '2016' and get an error that the date is unparseable. If I hardcode the first parameter to 'January-1-2016' it works. Any ideas on what I'm doing wrong or if there's another way to accomplish my goal? I want the user to select month and year and I then need to convert this to a date, using the first day of the month. Thank you.
asked
1 answers
1

You should try using 'MMM' when trying to parse a fully written month from string to datetime. Please give it a try.

parseDateTime($Month + '-' + $Day + '-' + $Year,'MMM-d-yyyy')
answered