convert string to date time

0
i have a string of data that i’m pulling directly from mysql. i can’t get it to convert to date format. this is the microflow that i use to bring in the data and my attempt to change the string:   this is how it is pulling in currently:   does anybody have any idea on how i could either convert to date or trim the time off the end?
asked
2 answers
3

Corina,

I think your parseDateTime function looks good – although you may need to add on the time component.  However, the problem in your screenshot is that you are trying to set a List to a datetime value.  You’ll want to set an attribute on an entity (or a microflow variable) to the the datetime value.

Hope that helps,

Mike

**EDIT**

I just looked at your microflow – if I understand what you’re trying to do, I think in your loop you should create an object in each loop and set the value of an attribute on that object to the datetime value.

**EDIT 2**

I made a small example as follows:

Domain model

Next, I made a small microflow that created a few records in Tickets entity like this:

And inside the loop, the create object action looks like this

I have highlighted differences in my parseDateTime from yours.  Note that parseDateTime is picky – the formats must match the string exactly.

Finally, I create a page with 2 datagrids, one for Tickets entity and one for DateTest entity, and a microflow button for the microflow I created.  I’ve included a screenshot below:

you’ll see that it converts the dates as it should.  The datetime values have a 12:00 AM time component because the parseDateTime call doesn’t include elements for the time portion of the string.

 

Hopefully this is helpful.  Let me know if you have any other questions

answered
1

In the loop, remove the activity ‘Add to List’ and add a activity ‘Change object’ with which you change object IteratorTickets

where MyDateTime is an extra attribute you add to entity Ticket.

answered