cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
swaseb
Level: Powered On

Date conversion

Hi,

 

I am recieving a javascript date (SendDate) object in below  json response in the middle of a flow.

{
  "Code": 1,
  "Message": "Executed successfully",
  "Result": [
    {
      "FilterId": 0,
      "FilterName": "No filter used",
      "FromEmail": "emailaddress",
      "FromName": "Name",
      "MailinglistId": [
        3623322857
      ],
      "MailinglistName": [
        "Just a name"
      ],
      "NewsletterId": 5726778,
      "NewsletterName": "Just a name",
      "NewsletterSubject": "",
      "SendDate": "/Date(1568020620000+0200)/",
      "SendQueueId": 2482323282,
      "StatusCode": 2,
      "StatusMessage": "Sent"
    }
  ]
}

 

Later in that flow a want to create a record in Dynamics CRM with that date in a date only field, so I need to convert 

 

/Date(1568020620000+0200)/   to  a timestamp with format 'yyyy-MM-dd'

 

How can I achieve this, really appreciate some help 🙂

Thanks

//S

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Date conversion

Hi @swaseb 

 

This is what you need to do.

 

date1.png

 

To convert the date I referenced this link

https://powerusers.microsoft.com/t5/Building-Flows/Got-a-recipe-for-converting-a-unix-timestamp-to-a...

 

The first compose expression is as follows:

first(split(last(split(items('Apply_to_each')?['SendDate'], '(')),'+'))
 
Next compose expression is as follows:
addseconds('1970-1-1', Div(int(outputs('Compose_2')),1000),'yyyy-MM-dd hh:mm:ss')
 
This is my test result:
date2.png
 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks

 
 
 


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



View solution in original post

4 REPLIES 4
Super User
Super User

Re: Date conversion

Hi @swaseb 

 

This is what you need to do.

 

date1.png

 

To convert the date I referenced this link

https://powerusers.microsoft.com/t5/Building-Flows/Got-a-recipe-for-converting-a-unix-timestamp-to-a...

 

The first compose expression is as follows:

first(split(last(split(items('Apply_to_each')?['SendDate'], '(')),'+'))
 
Next compose expression is as follows:
addseconds('1970-1-1', Div(int(outputs('Compose_2')),1000),'yyyy-MM-dd hh:mm:ss')
 
This is my test result:
date2.png
 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks

 
 
 


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



View solution in original post

Super User
Super User

Re: Date conversion

@swaseb 

Take a look at the formatDateTime() expression .  You can use it to convert any valid date/time to a yyyy-MM-dd format or any other date/time format.

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
swaseb
Level: Powered On

Re: Date conversion

Thanks @abm ,

 

Worked like a charm, though I had to "int" the second expression and use "+" as splitter to get rid of the figures after the plus sign as the flow did not think it was a valid date string.  

 

int(first(split(last(split(items('Apply_to_each')?['SendDate'], '(')),'+')))
 
Big thanks and have a nice week.
//S
Super User
Super User

Re: Date conversion

Hi @swaseb 

 

Glad to hear that it is working. I have edited my earlier reply by remvoing the hardcoded expression date function.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,926)