Skip to main content

Notifications

Community site session details

Community site session details

Session Id : plVx0MGCi5Mu0vWYxcZ6kN
Power Apps - Building Power Apps
Unanswered

Data Import from Excel - Dates / Times (Date Only, Time Only)

Like (0) ShareShare
ReportReport
Posted on 7 Jun 2022 08:54:50 by 402

Dear Power Apps Community,

 

The data for my Canvas App is sourced from an Excel file (.xlsx). This is a one-time (per App session) import process; once the data is in App, it is worked on within collections, etc. The Excel data needs to be directly from a standalone Excel file and not 'connected' via/to Excel Online due to the number of rows.

 

The issue I'm having is that to select the segment of the data the user needs to work with, they need to pick from a dropdown with a date and a second dropdown with a time. Those date and time values are fetched from the Excel file data source ('Distinct' from a Date column and a Time column).

 

The Excel file datasource is an export from a vast database and I want to try and avoid the end user having to manually apply formatting to the source data to avoid errors. But what I'm not sure on is how to restrict the 'Date' dropdown in Power Apps to only show the date, and the 'Time' to only show the time. Currently what I'm getting is:

 

Date Dropdown: dd/mm/yyyy tt:tt

Time Dropdown: dd/mm/yyyy tt:tt

 

This should be:

 

Date Dropdown: dd/mm/yyyy

Time Dropdown: tt:tt

 

In Excel I have inspected the formatting of the source columns. For date, this is "Category: Custom" and in type, "dd-mmm-yy".

For time, this is hh:mm.

 

So, in Excel, the formatting of the cells appears accurate in the formatting desired - as if Power Apps is forcibly adding time to date and date to time respectively.

 

I've added some screenshots of the dropdowns in the App and the formatting from Excel for the date column and time column.

 

Thank you very much for your help Power Apps community,

Edd

  • pp365 Profile Picture
    402 on 09 Jun 2022 at 18:24:45
    Re: Data Import from Excel - Dates / Times (Date Only, Time Only)

    Hi @timl ,

     

    Thanks, again, for your help with this. I am replying quickly now in case any of the Community are wanting to use the solution provided.

     

    In brief, I have got it working, the code you provided was a big help but I found there were still several steps I had to take to shape the data so it appeared as I needed it and then worked with the rest of the App. Naturally, these are part App-specific and part out of scope of my original question, but for the Community benefit I'm aiming to document these and provide the steps I took - but I'll have to get back to this.

     

    One important note for now, there was an extra bracket in the code which caused the 'Add Columns' to fail, so no bracket to close that part off, so should be:

     


     

     

    ClearCollect(colNewCollection,
     AddColumns(colExistingCollection,
     "CeremonyDateTime",
     DateTimeValue(Text(CeremonyDate, "yyyy-mm-dd") & " " & Hour(CeremonyTime) & ":" & Minute(CeremonyTime))
    )

     

     

     

  • pp365 Profile Picture
    402 on 09 Jun 2022 at 08:07:57
    Re: Data Import from Excel - Dates / Times (Date Only, Time Only)

    Thanks very much @timl for getting back to me, it's much appreciated. I'll try that fix and confirm accordingly. 

    Thank you again!

  • timl Profile Picture
    34,955 Super User 2025 Season 1 on 08 Jun 2022 at 11:31:59
    Re: Data Import from Excel - Dates / Times (Date Only, Time Only)

    @pp365 

    The way I would approach this is to combine the 2 "ceremony date" and "ceremony time" columns into a single "ceremony datetime" column in your underlying collection.

    To build a collection, you would use this type of formula (assuming that the name of your 2 source columns are CeremonyDate and CeremonyTime):

    ClearCollect(colNewCollection,
     AddColumns(colExistingCollection),
     "CeremonyDateTime",
     DateTimeValue(Text(CeremonyDate, "yyyy-mm-dd") & " " & Hour(CeremonyTime) & ":" & Minute(CeremonyTime))
    )
    

     

    If you then work from this new collection, it should hopefully solve the problems that you're experiencing.

  • pp365 Profile Picture
    402 on 08 Jun 2022 at 08:08:18
    Re: Data Import from Excel - Dates / Times (Date Only, Time Only)

    Hi all,

     

    I had an idea to use Left and Right to essentially trim off the unneeded data in the display for the user in the drop down. Whilst that worked fine for the visibility of the data in the drop down, I could not then use the drop down as a filter on the original data at source, as the two didn't match. 

     

    I collected the data from the source in to a collection then used a 'Left' or 'Right' on that collection to display the data in the drop down - in other words, the data is still matching the data at source in the collection. What I am now stuck on is how to relate back the item selected in the drop down to the "source" data in the Collection which could then be used to match against the data at source.

     

    Any help from anyone on this would be greatly appreciated, I've wasted several hours on this and presumably this issue is not exclusive to me. Thanks very much all!

  • pp365 Profile Picture
    402 on 07 Jun 2022 at 17:24:19
    Re: Data Import from Excel - Dates / Times (Date Only, Time Only)

    Hi @WarrenBelz , @RandyHayes , @timl ,

     

    Please excuse the direct approach here but as regular 'Solution Providers', I was wondering if you could take a look at this issue if you have a moment. I'm hoping to bring this App to production very shortly and am unsure how to resolve this.

     

    I would be really grateful for any responses from any of the community members and thanks again!

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard
Loading started
Loading complete