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

Date issue in iPhone

I am having an issue where my code works correctly in Android phones and incorrectly in iPhone.

Here is my code:

*****************************************

Set(DateVar,DateValue(Left(AvlDatesListBox.Selected.DateNDay,Find("-",AvlDatesListBox.Selected.DateNDay))));

--A sample value for the DateNDay value is:  09/30/2019-Mon

*******************************************

This code works fine in Android phones and returns 9/30/2019 for DateVar value. But it does not work in iPhone and returns a blank value for DateVar

Any thoughts on what could be going wrong?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @prasadvenkat ,

Based on the formula you provided, I found that there is something wrong with it. The Left(AvlDatesListBox.Selected.DateNDay,Find("-",AvlDatesListBox.Selected.DateNDay)) formula would return "09/30/2019-" (including '-' at the end) rather than "09/30/2019".

 

Please consider modify your formula as below:

Set(
DateVar,
DateValue(
Left(AvlDatesListBox.Selected.DateNDay, Find("-", AvlDatesListBox.Selected.DateNDay) - 1) /* <-- Modify formula here */
)
)

In additon, you could also consider take a try with the following formula:

Set(
    DateVar,
    DateValue(
              First(Split(AvlDatesListBox.Selected.DateNDay, "-")).Result   /* <-- Modify formula here */
    )
)

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Super User III
Super User III

@prasadvenkat 

While I don't have access to both Android and iPhone, I wonder if you could use the Text() function to format the datetime so it appears correctly on both mobile phones.  Try this:

 

Set(DateVar,Text(DateValue(Left(AvlDatesListBox.Selected.DateNDay,Find("-",AvlDatesListBox.Selected.DateNDay))),"m/d/yyyy");

 

The Text() function takes two arguments: the 1st is a date/number variable and the 2nd is formatting instructions in a text string format.  I think the result of the formula will now be 9/30/2019 on both phones.  Let me know

Community Support
Community Support

Hi @prasadvenkat ,

Based on the formula you provided, I found that there is something wrong with it. The Left(AvlDatesListBox.Selected.DateNDay,Find("-",AvlDatesListBox.Selected.DateNDay)) formula would return "09/30/2019-" (including '-' at the end) rather than "09/30/2019".

 

Please consider modify your formula as below:

Set(
DateVar,
DateValue(
Left(AvlDatesListBox.Selected.DateNDay, Find("-", AvlDatesListBox.Selected.DateNDay) - 1) /* <-- Modify formula here */
)
)

In additon, you could also consider take a try with the following formula:

Set(
    DateVar,
    DateValue(
              First(Split(AvlDatesListBox.Selected.DateNDay, "-")).Result   /* <-- Modify formula here */
    )
)

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

great..thx.  worked perfect for me. I like the split function.. din't realize powerapps has a split like in traditional scripting languages

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (76,899)