cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Incorrect date conversion

Hi,

I have a SP List in which the date and time are stored as text string:

 

dd/mm/yyyy hh:mm

 

I am using AddColumn in a collect statement to convert this text string to DateTimeValue

 

ClearCollect(colB,Sort(AddColumns(MA_Timetable_2,"START",DateTimeValue(EventStart),"END",DateTimeValue(EventEnd)),ID,Ascending))

 

The problem is the date is being converted incorrectly.

 

Mo_Islam_1-1603410949596.png

 

Any help or guidance would be much appreciated.

 

What am I doing wrong?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

Hi @Mo_Islam ,

You are using a "dd/mm/yyyy" system to collect your data as text in SharePoint and DateTimeValue recognized datetime type implicit in "mm/dd/yyyy". That why the conversion gives a datetime value where your day is recognized as month (because is greater that 12 it add a year and give you the remaining month), and your month is recognized as day.

 

In other words to solve your problem, you have to set language_code parameter of function DateTimeValue to one similar to your data format saved in Sharepoint (i think "fr").

 

Your new formula is: 

ClearCollect(colB,Sort(AddColumns(MA_Timetable_2,"START",DateTimeValue(EventStart,"fr"),"END",DateTimeValue(EventEnd,"fr")),ID,Ascending))

and should working fine.

 

Hope it helps ! 

View solution in original post

1 REPLY 1
Highlighted
Memorable Member
Memorable Member

Hi @Mo_Islam ,

You are using a "dd/mm/yyyy" system to collect your data as text in SharePoint and DateTimeValue recognized datetime type implicit in "mm/dd/yyyy". That why the conversion gives a datetime value where your day is recognized as month (because is greater that 12 it add a year and give you the remaining month), and your month is recognized as day.

 

In other words to solve your problem, you have to set language_code parameter of function DateTimeValue to one similar to your data format saved in Sharepoint (i think "fr").

 

Your new formula is: 

ClearCollect(colB,Sort(AddColumns(MA_Timetable_2,"START",DateTimeValue(EventStart,"fr"),"END",DateTimeValue(EventEnd,"fr")),ID,Ascending))

and should working fine.

 

Hope it helps ! 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (12,916)