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 / Patch Date to Azure SQ...
Power Apps
Answered

Patch Date to Azure SQL not working

(0) ShareShare
ReportReport
Posted on by 1,855

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.

Categories:
I have the same question (0)
  • Verified answer
    wyotim Profile Picture
    2,545 on at

    @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*

  • seadude Profile Picture
    1,855 on at

    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
     })
  • Verified answer
    wyotim Profile Picture
    2,545 on at

    @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
     })
  • seadude Profile Picture
    1,855 on at

    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.

  • wyotim Profile Picture
    2,545 on at

    Happy that I could help!

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard