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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Define collection colu...
Power Apps
Answered

Define collection column to date/time format

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

I need to patch a date from a collection into a SharePoint list.   The time will be static for every entry.   It seems like a lot of extra work to patch the collection with a text value that has been formatted with a date/time format and then have to manipulate it even more to patch it to a SharePoint date/time column.

 

This is what I use when I am patching date/time to a single line of text field that has to have a date/time format for further use.

 

datetimetext.png

 

I was thinking it might be easier to define the collection date column on initialization into a date/time column if it's possible, in a similar way that you define a column as a number rather than text but I am not sure how I would include the time.

 

I have this so far:

 

Collect(
colEffort,
{

BusinessGroup: {

Id: 1,
Value: ""
},

ProductCategory: {

Id: 1,
Value: ""
},
Effort: "",
WeekEnding: 12/01/2020,
Manager: "",
Developer: "",
ShowSave: true
}

);

Patch(colEffort,

First(colEffort),

{
BusinessGroup: Blank(),
ProductCategory: Blank(),
WeekEnding: Blank()

}

)

 

 

 

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @JR-BejeweledOne 

     

    Check this answer in other post, it may be exactly what you need!

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Patch-function-to-write-date-time-field-back-to-SharePoint/m-p/38060#M15782

     

     

    See you!

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I was able to define that column when initializing the collection like so:

     

    Collect(
    colEffort,
    {
    WeekEnding: Now(),
    ShowSave: true
    }

    );

    Patch(colEffort,

    First(colEffort),

    {
    WeekEnding: Blank()

    }

    )

     

    Now I just need to get the correct syntax to take that from the collection to my SharePoint list date/time column.

     

     

     

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @JR-BejeweledOne ,

     

    If Date Column in Collection and SharePoint list are all Date type, there is no need to convert the date to text, just patch the date in collection to sharepoint list directly.

    for example:

    Patch('SP list',First('SP list'),{DateColumn:First(colEffort).WeekEnding})

     

    Hope this helps

    Sik

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    As indicated I have defined the column as Date/Time and then set it to a blank value during App on start.   However I am running into an error with the patch.   It seems to be related to setting the value and then clearing it during the initial app load as I get the same error with another column that I set initially and then clear.

     

    EffortWeekEndingError.png

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @JR-BejeweledOne ,

     

    There are some mistakes when using ForAll function. 

    If you want to refer to the value form colEffort, you only need to use ColumnName to reference the value. And the colEffort.ProductCategory you used mean a single-column table which caused the error.

     

    Please try this.

    ForAll(colEffort, Patch('SP list', Defaults('SP list'), { 'Product Category': ProductCategory, 'Week Ending': WeekEnding})

    Hope this helps.

    Sik

  • Verified answer
    JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    It wasn't accepting that and I am patching from a collection.   I did eventually figure it out.    

     

    I was missing a ';' in my app on start formulas and it was causing an error there.   Once I fixed that it accepted my patch formula.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 337 Most Valuable Professional

#2
11manish Profile Picture

11manish 173

#3
Valantis Profile Picture

Valantis 86

Last 30 days Overall leaderboard