SQL Date Column:
[date] DATE NOT NULL
Excerpt from PowerApps Patch command for date field:
date: Text(status_date.Text,"[$-en-US]yyyy-mm-dd")
Error:
This type of argument 'date' does not match the expected type 'Date'. Found type 'Text'.
What am I missing here? Per the SQL docs, a DATE-type column needs yyyy-mm-dd format. Thought that is what I was doing.
Solved! Go to Solution.
@seadudeYou may try wrapping the Text() section in a DateValue(). Like this:
date: DateValue(Text(status_date.Text,"[$-en-US]yyyy-mm-dd"))
*edit for typo*
@seadudeI think the issue is that there isn't a statement in that Patch code for the base record to Patch, either a new one using Defaults('[dbo].[QSelf]') or an existing one using some filter like First(Filter('[dbo].[QSelf]', user=status_user.Text)).
If these are new records only, try:
Patch('[dbo].[QSelf]', Defaults('[dbo].[QSelf]'), { lat: status_lat.Text, long: status_long.Text, altitude: status_alt.Text, user: status_user.Text, notes: input_notes.Text, image: text_takenImage.Text, date: DateValue(Text(status_date.Text)), time: status_time.Text })
Otherwise, you will need to create the filter to edit the record you want like:
Patch('[dbo].[QSelf]', First(Filter('[dbo].[QSelf]', *your filter criteria here*)), { lat: status_lat.Text, long: status_long.Text, altitude: status_alt.Text, user: status_user.Text, notes: input_notes.Text, image: text_takenImage.Text, date: DateValue(Text(status_date.Text)), time: status_time.Text })
@seadudeYou may try wrapping the Text() section in a DateValue(). Like this:
date: DateValue(Text(status_date.Text,"[$-en-US]yyyy-mm-dd"))
*edit for typo*
Nice work @wyotim! Thanks for the solution.
Interestingly, when I applied the `DateValue()` wrap, a different error popped up:
The first argument of 'Patch' should be a collection.
Can I not patch directly to SQL? The table below, '[dbo].[QSelf]', shows up in intellisense and is definitely the name of the table in SQL. What gives?
Patch('[dbo].[QSelf]', { lat: status_lat.Text, long: status_long.Text, altitude: status_alt.Text, user: status_user.Text, notes: input_notes.Text, image: text_takenImage.Text, date: DateValue(Text(status_date.Text)), time: status_time.Text })
@seadudeI think the issue is that there isn't a statement in that Patch code for the base record to Patch, either a new one using Defaults('[dbo].[QSelf]') or an existing one using some filter like First(Filter('[dbo].[QSelf]', user=status_user.Text)).
If these are new records only, try:
Patch('[dbo].[QSelf]', Defaults('[dbo].[QSelf]'), { lat: status_lat.Text, long: status_long.Text, altitude: status_alt.Text, user: status_user.Text, notes: input_notes.Text, image: text_takenImage.Text, date: DateValue(Text(status_date.Text)), time: status_time.Text })
Otherwise, you will need to create the filter to edit the record you want like:
Patch('[dbo].[QSelf]', First(Filter('[dbo].[QSelf]', *your filter criteria here*)), { lat: status_lat.Text, long: status_long.Text, altitude: status_alt.Text, user: status_user.Text, notes: input_notes.Text, image: text_takenImage.Text, date: DateValue(Text(status_date.Text)), time: status_time.Text })
You're exactly right. I was missing the (in my case) the Defaults line to tell PowerApps to create a new record in the table.
Thank you.
Happy that I could help!
User | Count |
---|---|
255 | |
114 | |
94 | |
48 | |
38 |