web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Limitations with date ...
Power Apps
Answered

Limitations with date and time fields and how to overcome

(0) ShareShare
ReportReport
Posted on by

 I'm struggling to find the best solution.  I've looked at a million options and ideas but I can't seem to get it right.

 

I need to achieve the following.

 

Have a user enter a date and a time and calculate the number of hours since that date/time   It needs to be dynamic so that if I login to the app an hour later the time has increased by an hour.   Seems straightforward !     I just can't get it !

 

Any suggestions on how I should set this up?  Ideally I need the date to be a date column in sharepoint as I need to do other stuff with it later.. if it can't be then I can try work around that, I know the time column is going to have to be a single line text field as sharepoint doesn't have time only fields !  

 

Any help gratefully received as this is driving me nuts

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    So you are stating that you have a user enter a Date and that Date and time is stored in your SharePoint (and by the way, yes SharePoint will allow you to have times on your dates).  When you start your App again, you want to get that value from the datasource (SharePoint) and then do your calculation.

     

    If your calculation is based on the current time, then a Label with the following:

        DateDiff(LookUp(yourList, <criteria for Lookup>, DateTimeColumn), Now(), Hours)

    will give you the dynamic difference each time.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    on at

    Thanks @RandyHayes   I may not have explained myself properly. I need them to add in a specific date and time not a dynamic one.  So they need to enter  30 November 2020   1.35pm    and I  need to know how many hours it is from 1.35pm on the 30th of November to today.. I know sharepoint allows you to show the time and you can also use a calculated column to subtract the time out of a date/time field but I can't find a way to add a specific time to that date/time field as I've described above..   thanks

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    So, I'm not sure that I am completely understanding your scenario then.

     

    If they enter a date and time and you just want to know the amount of hours since that time up to now, then, let's say you have a TextInput for the date and time (datePicker and time dropdowns would be better, but let's stay simple for the moment).  We'll call that TextInput txtDateTime.

     

    If you then have a label with the following formula:

    DateDiff(DateTimeValue(txtDateTime.Text), Now(), Hours)

    This will show the number of hours since that entry.

     

    I am a little confused on where your SharePoint list comes into play in this.  

    If you are then storing the date and time they entered, then in the future when you return to that record, you would just use the same formula except based on the value in the column in your list.

  • Community Power Platform Member Profile Picture
    on at

    Maybe I'm over complicating this LOL.    If I can add the date and time into one label and use that then brilliant will work. I know I use datevalue to turn label into date but how exactly do I need to show the date and time in the label?  Do I separate date from time with a comma? or how should I structure it?

     

    thanks for your help

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    I'm a little confused.  You were trying to get the number of hours between the entered time and the current date - that would be a number, not a date.  

    What are you trying to show in a label (which would be a date)?  I though the users were entering the date?

  • Community Power Platform Member Profile Picture
    on at

    ok so I need the users to enter a date and a time.   eg.  30th of November 2020 11.00am       I then need to calculate the number of hours from that date and time till now this minute.      I need the date AND time to be saved in the sharepoint data source.  Ideally I would like the dynamic calculation of hours from then to now to be at the data source end but if that's not possible then I will do the calculation in a label.

     

    So I'm looking to understand what I need to do at the sharepoint end? eg. will I store the date in a date/time field and the time in a text field? and what do I need to do at the powerapp end .

     

     

    Hope that explains it ! 😁

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    Yes, so I would just store the date and time in SharePoint.  All you need is a Date and Time column in SharePoint, there is no need to store time in text.  Then in your PowerApp, do the calculation for the elapsed time since that date.  Trying to do in both places (with a calculated field) will not work as SharePoint will not constantly evaluate the difference.  In other words, when you create the record, the calculated field is calculated and stored.  It will not continue to update dynamically.  So, in your App is best!

  • Community Power Platform Member Profile Picture
    on at

    Thanks so how do I store a specific time in sharepoint from powerapps?  If I use the date and time type control it only allows me to put a date.  Do I use a text field formatted a certain way and and use the datevalue line in the update ?

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    Well...depends.  You originally stated that you had a TextInput control where users were entering the value (not really recommended).  

    I would recommend a DatePicker and three dropdowns.

     

    DatePicker is pretty obvious - let's call it dpDate

    Next, add a Dropdown and call it ddHour.  Set the Items property to Sequence(12)

    Add another Dropdown and call it ddMinute. Set the Items property to : ForAll(Sequence(60, 0), Text(Value, "00"))

    Add another Dropdown and call it ddAmPm. Set the Items property to : ["AM", "PM"]

     

    Now, if you want the date and time to write to your SharePoint list, then use this in your formula:

       DateTimeValue(Text(dpDate.SelectedDate, ShortDate) & " " & ddHour.Selected.Value & ":" & ddMinute.Selected.Value & " " & ddAmPm.Selected.Value)

     

    This will return a complete date and time value that can be written to the datasource.

     

    Make sure your SharePoint date column includes times, then implement this into your app.

    Get this going and then let me know when you get to the "displaying a previously entered date" part of your scenario as you will need to do some setting of Default properties to set the dropdowns properly based on the prior entered value.

  • Community Power Platform Member Profile Picture
    on at

    Great thank you so much. I've gotten that part working and updating back to the sharepoint.. so I need to now calculate (dynamically) the  number of hours between this date and time and the current date and time.  I've tried playing with the info you gave in one of the first responses but that was for a text field my data is now in a DP field so can't quite get it right 😀

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard