Hello
I am using Excel as the data source for a GALLERY (not a form)
How do I patch a date using the date picker control back to an Excel cell?
Many thanks in advance for any suggestions!
Solved! Go to Solution.
Hi @Englishweb ,
I assume you already have a column to hold the date (let's call it MyDateColumn) in your source (let's call it MyExcelSpreadsheet) and a datepicker control inside the gallery?
If you want a button, add it to the gallery row (so the button appears in each row of the gallery). If you want a single button outside the gallery to patch multiple changes - that's going to be a very different post.
To make things easier, let's assume you just want to update the row any time the date is changed.
Set the OnChange: property of the datepicker control to
Patch(MyExcelSpreadsheet, ThisItem, {MyDateColumn: DatePicker.Selected.Date})
For a row button, it would be the same formula but applied to the OnSelect: property.
Hope this helps,
RT
Hi @Englishweb ,
I assume you already have a column to hold the date (let's call it MyDateColumn) in your source (let's call it MyExcelSpreadsheet) and a datepicker control inside the gallery?
If you want a button, add it to the gallery row (so the button appears in each row of the gallery). If you want a single button outside the gallery to patch multiple changes - that's going to be a very different post.
To make things easier, let's assume you just want to update the row any time the date is changed.
Set the OnChange: property of the datepicker control to
Patch(MyExcelSpreadsheet, ThisItem, {MyDateColumn: DatePicker.Selected.Date})
For a row button, it would be the same formula but applied to the OnSelect: property.
Hope this helps,
RT
Hello RT
Thank you so much for your quick reply.
I'm getting an error message: MyDateColumn does not match the expected type 'DateTime'.
Do I need to format the Excel column as a date or leave it as General?
Sorry if the question is obvious!!
Thanks
Hi @Englishweb ,
For Excel I'm not sure how well data types carry through to PowerApps - but you can just make it text using the Text() function if the source column is Text - so;
Patch(MyExcelSpreadsheet, ThisItem, {MyDateColumn: Text(DatePicker.Selected.Date, "dd/mm/yyyy")})
You can decide on the format using dd mm yyyy in whichever order you want, or for easier conversion back into date format inside PowerApps use one of the built in formats (like ShortDate) and use the region code to format - so;
Patch(MyExcelSpreadsheet, ThisItem, {MyDateColumn: Text(DatePicker.Selected.Date, ShortDate, "en-US")})
Different region codes will put the month, day or year in different places, so play with US, GB
Some reading for reference:
Hope this helps,
RT
User | Count |
---|---|
251 | |
102 | |
94 | |
48 | |
37 |