cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lukas1
Advocate III
Advocate III

Convert text to date and save it in Sharepoint list

Hi,

 

I am trying to convert a string to a date-variable that is accepted by sharepoints date-format:

 

I have a string-variable:

Set(varDateEN;"12/31/2020")

 

I convert this string into date-format: 

Date(Value(Right(varDateEN;4));Value(Left(varDateEN;2));Value(Mid(varDateEN;4;2)))

 

Then I update an item in a sharepoint list including the date value. All values of the item are being updated, except the date.

 

Any ideas what's going wrong? Is there an easier way to convert text to date?

 

Thanks,

Lukas

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

 @Lukas1 ,'Have you tried simply

DateValue(varDateEN)

 as per DateValue function 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

6 REPLIES 6
WarrenBelz
Super User
Super User

 @Lukas1 ,'Have you tried simply

DateValue(varDateEN)

 as per DateValue function 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz , yes I tried. Doesn't work either.

Hi @Lukas1 ,

Actually you should need

DateValue(varDateEN,"en-US")

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

 

@WarrenBelz , thanks a lot for your help!

 

It is still not working. Please have a look at the preview below, I would expect it to be "7/22/2020", but instead it is "22.7.2020":

Bildschirmfoto 2020-07-22 um 13.13.16.png

 

I also tried this without success:

DateValue(varDateEN;"mm/dd/yyyy")

 

@Lukas1 ,

What regional code do you have on your SharePoint server? It will convert a date to the local format (and I can see this on the bottom of your code). The fact it converts and shows 22.7.2020 means it is a valid date on the source (there are not 22 months in a year).

This is also the reason for my first post (you do not need to specify the format if it matches the local format). You cannot store 07/22/2020 format as a date if the source is dd.mm.yyyy

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

 

@WarrenBelz That's it! I was confused because the dates in my sharepoint list are shown in the US-date-format:

Bildschirmfoto 2020-07-22 um 13.14.36.png

 

Anyway, DateValue() with a german date-format is doing the job now.

 

Thanks again.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,077)