Create event in Flow uses wrong time format but only when date is larger than 12

%3CLINGO-SUB%20id%3D%22lingo-sub-1101379%22%20slang%3D%22en-US%22%3ECreate%20event%20in%20Flow%20uses%20wrong%20time%20format%20but%20only%20when%20date%20is%20larger%20than%2012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1101379%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22_5pbx%20userContent%20_3576%22%3E%3CP%3EI%20am%20having%20great%20difficulty%20with%20a%20flow%20where%20I%20have%20an%20input%20date%20in%20this%20format%3A%20'dd-MM-yyyy%20hh%3Amm'%20and%20I%20want%20the%20flow%20to%20create%20an%20event%20on%20that%20specific%20time.%3CBR%20%2F%3EI%20have%20used%20this%20function%3A%3CBR%20%2F%3EformatDateTime(%5Binput%20data%5D%2C'dd-MM-yyyy%20hh%3Amm')%3CBR%20%2F%3EIt%20works%20fine%20for%20'09-03-2020%2010%3A00'%2C%20but%20not%20for%20'14-03-2020%2010%3A00'.%3CBR%20%2F%3ESee%20the%20picture%20-%20this%20is%20the%20event%20correctly%20created%20in%20my%20calendar%20for%20the%20input%3CBR%20%2F%3E'09-03-2020%2010%3A00'.%3C%2FP%3E%3CP%3EAt%20the%20bottom%2C%20the%20date%20in%20the%20text%20is%20the%20output%20of%20the%20exact%20same%20function%20as%20the%20one%20used%20to%20create%20the%20event.%3C%2FP%3E%3CP%3ESo%20why%20does%20it%20turn%20the%20date%20and%20month%20around%2C%20when%20it%20is%20correctly%20added%20to%20the%20calendar%2C%20and%20why%20is%20it%20not%20able%20to%20process%20the%20second%20input%20example%3F%3C%2FP%3E%3C%2FDIV%3E%3CDIV%20class%3D%22_3x-2%22%3E%3CDIV%3E%3CDIV%20class%3D%22mtm%22%3E%3CDIV%20class%3D%22_5cq3%20_1ktf%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1101379%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1103855%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20event%20in%20Flow%20uses%20wrong%20time%20format%20but%20only%20when%20date%20is%20larger%20than%2012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1103855%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F450014%22%20target%3D%22_blank%22%3E%40Maria_DK%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'll%20make%20some%20assumptions%20here%20as%20there's%20some%20missing%20pieces%20to%20your%20puzzle.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20your%20date%20format%20is%20already%20input%20in%20the%20right%20format%20(e.g.%2014-03-2020)%20then%20the%20expression%20you%20use%20will%20switch%20the%20numbers%20around%20to%20be%2003-14-2020%20which%20will%20give%20you%20the%20error%20you%20have%20seen.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F164954i9C415E9F78DF53D3%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20the%20date%20is%20captured%20as%20MM-dd-yyyy%20(e.g.%2003-14-2020)%20then%20your%20expression%20will%20correctly%20switch%20it%20around%20to%20dd-MM-yyyy%20(14-03-2020).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F164953iD1B4F24E88560652%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBased%20on%20what%20you%20have%20in%20the%20Event%20body%20where%20the%20date%20has%20switched%20to%2003-09-2020%2C%20are%20you%20sure%20that%20this%20is%20the%20same%20expression%20as%20the%20create%20event%20one%3F%20It%20would%20seem%20to%20be%20formatted%20as%20MM-dd-yyyy.%20Might%20be%20worth%20revisiting%20the%20expression%20for%20that%20bit.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20can%20provide%20a%20screen%20grab%20of%20the%20Create%20Event%2C%20it%20would%20help%20to%20see%20what%20might%20have%20gone%20wrong%20if%20the%20above%20hasn't%20helped%20diagnose%20the%20issue.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20would%20also%20be%20helpful%20to%20know%20how%20the%20date%20is%20initially%20captured%2C%20as%20I%20suspect%20the%20issue%20is%20to%20do%20with%20how%20you%20capture%20the%20date.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20wishes%3C%2FP%3E%3CP%3EDamien%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1103858%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20event%20in%20Flow%20uses%20wrong%20time%20format%20but%20only%20when%20date%20is%20larger%20than%2012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1103858%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20again%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F450014%22%20target%3D%22_blank%22%3E%40Maria_DK%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAdditionally%2C%20I%20also%20use%20Convert%20time%20zone%20to%20ensure%20that%20the%20initial%20date%20captured%20is%20properly%20converted%20to%20my%20desired%20format%20for%20my%20time%20zone.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F164956iE1B98DBE6553479D%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20may%20find%20using%20this%20to%20be%20more%20useful%20than%20the%20expression!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3EDamien%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1106978%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20event%20in%20Flow%20uses%20wrong%20time%20format%20but%20only%20when%20date%20is%20larger%20than%2012%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1106978%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F89704%22%20target%3D%22_blank%22%3E%40Damien%20Rosario%3C%2FA%3E%2C%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20reply.%3CBR%20%2F%3EThe%20date%20is%20captured%20from%20a%20choice%20text%20field%20in%20a%20Form%2C%20where%20I%20have%20written%20the%20date%20as%20'09-03-2020%2010%3A00'.%20So%20there%20is%20no%20date%20format%20in%20the%20input%20itself%2C%20it%20is%20only%20a%20string.%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20screenshot%20you%20can%20see%20how%20I%20create%20the%20event.%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EStart%20time%20expression%20is%20this%3A%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EformatDateTime(body(%3C%2FSPAN%3E%3CSPAN%3E'Hent_detaljer_om_svar'%3C%2FSPAN%3E%3CSPAN%3E)%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'rb52e2fa728e143a495c028f3b15dcf57'%3C%2FSPAN%3E%3CSPAN%3E%5D%2C%3C%2FSPAN%3E%3CSPAN%3E'dd-MM-yyyy%20hh%3Amm'%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F165262iB82D7FCB0D877FD9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20expression%20in%20the%20text%20is%20an%20exact%20copy%20of%20the%20one%20in%20the%20start%20time%20expression.%3C%2FP%3E%3CP%3EAs%20I%20have%20set%20the%20time%20zone%20in%20the%20event%20itself%2C%20I%20do%20not%20see%20the%20need%20for%20converting%20time%20zone%20here.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20do%20not%20specify%20any%20format%2C%20the%20event%20is%20created%20at%20the%20wrong%20date.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20you%20saying%20that%20if%20my%20input%20is%20in%20the%20correct%20format%20and%20I%20use%20formatDateTime%20to%20make%20sure%20it%20keeps%20that%20format%2C%20it%20then%20changes%20the%20format%3F%20That%20makes%20no%20sense%20to%20me.%20And%20I%20cannot%20see%20how%20else%20I%20should%20turn%20the%20input%20into%20a%20date%20so%20I%20can%20use%20it%20for%20creating%20an%20event.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20you%20can%20see%20the%20input%20and%20output%20from%20running%20the%20flow%3A%26nbsp%3B%3C%2FP%3E%3CP%3EForm%20output%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F165267i3AE5F054EF7C99EA%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_2.png%22%20title%3D%22clipboard_image_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECreate%20event%20input%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F165268iB1ECEC1965B593C1%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_3.png%22%20title%3D%22clipboard_image_3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ECreate%20event%20output%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F165269iD0D0BC6BE8E16435%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_4.png%22%20title%3D%22clipboard_image_4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I am having great difficulty with a flow where I have an input date in this format: 'dd-MM-yyyy hh:mm' and I want the flow to create an event on that specific time.
I have used this function:
formatDateTime([input data],'dd-MM-yyyy hh:mm')
It works fine for '09-03-2020 10:00', but not for '14-03-2020 10:00'.
See the picture - this is the event correctly created in my calendar for the input
'09-03-2020 10:00'.

At the bottom, the date in the text is the output of the exact same function as the one used to create the event.

So why does it turn the date and month around, when it is correctly added to the calendar, and why is it not able to process the second input example?

 
3 Replies
Highlighted

Hi @Maria_DK 

 

I'll make some assumptions here as there's some missing pieces to your puzzle.

 

If your date format is already input in the right format (e.g. 14-03-2020) then the expression you use will switch the numbers around to be 03-14-2020 which will give you the error you have seen.

 

clipboard_image_1.png

 

If the date is captured as MM-dd-yyyy (e.g. 03-14-2020) then your expression will correctly switch it around to dd-MM-yyyy (14-03-2020).

 

clipboard_image_0.png

 

Based on what you have in the Event body where the date has switched to 03-09-2020, are you sure that this is the same expression as the create event one? It would seem to be formatted as MM-dd-yyyy. Might be worth revisiting the expression for that bit.

 

If you can provide a screen grab of the Create Event, it would help to see what might have gone wrong if the above hasn't helped diagnose the issue.

 

It would also be helpful to know how the date is initially captured, as I suspect the issue is to do with how you capture the date.

 

Best wishes

Damien

Highlighted

Hi again @Maria_DK 

 

Additionally, I also use Convert time zone to ensure that the initial date captured is properly converted to my desired format for my time zone.

 

clipboard_image_0.png

 

You may find using this to be more useful than the expression!

 

Cheers

Damien

Highlighted

Hi @Damien Rosario

Thank you for your reply.
The date is captured from a choice text field in a Form, where I have written the date as '09-03-2020 10:00'. So there is no date format in the input itself, it is only a string. 

In the screenshot you can see how I create the event.

Start time expression is this:
formatDateTime(body('Hent_detaljer_om_svar')?['rb52e2fa728e143a495c028f3b15dcf57'],'dd-MM-yyyy hh:mm')

clipboard_image_1.png

 

The expression in the text is an exact copy of the one in the start time expression.

As I have set the time zone in the event itself, I do not see the need for converting time zone here.

 

If I do not specify any format, the event is created at the wrong date.

 

Are you saying that if my input is in the correct format and I use formatDateTime to make sure it keeps that format, it then changes the format? That makes no sense to me. And I cannot see how else I should turn the input into a date so I can use it for creating an event.

 

Here you can see the input and output from running the flow: 

Form output: 

clipboard_image_2.png

 

Create event input:

clipboard_image_3.png

Create event output: 

clipboard_image_4.png