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 Automate / Error in SQL type mism...
Power Automate
Unanswered

Error in SQL type mismatch in criteria expression power automate desktop

(0) ShareShare
ReportReport
Posted on by 165

Hi I am trying to filter a date column in power automate desktop.
i am getting an error which says Error in SQL type mismatch in criteria expression

What would i be doing wrong

SELECT [full name], [position code],
 SUM(IIF([project number] = 'OPERATING EXPENSE', [work codes], 0)) AS opex_hours,
 SUM([work codes]) - SUM(IIF([project number] = 'OPERATING EXPENSE', [work codes], 0)) AS capex_hours,
 IIF(SUM([work codes]) = 0, NULL, ROUND((SUM([work codes]) - SUM(IIF([project number] = 'OPERATING EXPENSE', [work codes], 0))) / SUM([work codes]) * 100, 2)) AS capex_percentage
FROM [Timesheet Detailed Report$]
WHERE [Work Date] >= DATE() - WEEKDAY(DATE()) - 6
 AND [Work Date] <= DATE() - WEEKDAY(DATE()) - 1
GROUP BY [full name], [position code]

 

damiosiks_0-1688998897497.png

 

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    I assume you're using MySQL based on the WEEKDAY() function. Deducting integers from a date is not a valid functionality. Try using DATE_SUB(). See this article for reference: https://learnsql.com/cookbook/how-to-get-yesterdays-date-in-mysql/

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution.

    If you like my response, please give it a Thumbs Up.

     

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

     

  • damiosiks Profile Picture
    165 on at

    Hi @Agnius im using SQL and not MySQL.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If by "SQL" you mean SQL Server, you should use DATEADD(). See here for reference: https://learnsql.com/cookbook/how-to-subtract-30-days-from-a-date-in-t-sql/

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution.

    If you like my response, please give it a Thumbs Up.

     

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 474

#2
11manish Profile Picture

11manish 268

#3
David_MA Profile Picture

David_MA 243 Super User 2026 Season 1

Last 30 days Overall leaderboard