Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ChadiLouca
Regular Visitor

Passing a Date/Time Variable inside a SQL Query in Dataflow Advanced Editor

I want to load data daily from MySQL to Fabric Lakehouse using Dataflow.
My technique is to get the maximum DateCompleted and get the data from MySQL bigger than this value.
I have 2 queries in my dataflow. The first "PGW_Payment_Transactions_LH" calculates the Maximum Date/Time from DateCompleted Column from the table in Lakehouse.


The second query Loads the data from MySQL.

This is the Query I am using:

 

let
    MaxDateCompleted = #"PGW_Payment_Transactions_LH",
    Source = MySQL.Database("Server Name", "Database Name", [Query = "SELECT #(lf)id,#(lf)partition_id,#(lf)date_created,#(lf)date_completed,#(lf)country_code,#(lf)payment_provider_code,#(lf)payment_provider_type,#(lf)integration_service_id,#(lf)revenue_share_id,#(lf)provider_tran_id,#(lf)client_correlation_id,#(lf)payment_acct_num,#(lf)merchant_code,#(lf)merchant_name,#(lf)service_category,#(lf)merchant_correlation_id,#(lf)payment_type,#(lf)product_id,#(lf)product_desc,#(lf)subscription_id,#(lf)provider_subscription_id,#(lf)amount,#(lf)currency_code,#(lf)status,#(lf)provider_response_code,#(lf)verification_type,#(lf)verification_instruction,#(lf)verification_token, 'PROD'  As  SourceDb,#(lf)#(tab) DATE_FORMAT(NOW(), '%Y%m%d%H%m%s') AS ETLRunDate#(lf)FROM payment_transactions#(lf)#(lf)WHERE date_completed  " > & MaxDateCompleted ])
in
  Source

 

It gives me this error:

 

Expression.Error: We cannot apply operator & to types Text and DateTime.DetailsReason = Expression.Error
Operator = &
Left = SELECT 
id,
partition_id,
date_created,
date_completed,
country_code,
payment_provider_code,
payment_provider_type,
integration_service_id,
revenue_share_id,
provider_tran_id,
client_correlation_id,
payment_acct_num,
merchant_code,
merchant_name,
service_category,
merchant_correlation_id,
payment_type,
product_id,
product_desc,
subscription_id,
provider_subscription_id,
amount,
currency_code,
status,
provider_response_code,
verification_type,
verification_instruction,
verification_token, 'PROD'  As  SourceDb,
   DATE_FORMAT(NOW(), '%Y%m%d%H%m%s') AS ETLRunDate
FROM payment_transactions

 

WHERE date_completed >
Right = 5/16/2024 4:01:01 AM

 

Is there a solution for this issue?

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Date.ToText - PowerQuery M | Microsoft Learn

Make sure you format the text correctly. Ideally that should be in ISO-8601 format.

 

Your closing double quotes are in the wrong place too.

View solution in original post

2 REPLIES 2
watkinnc
Super User
Super User

Change

 date_completed  " > & MaxDateCompleted ])

 

to

 

date_completed  > "& MaxDateCompleted ])

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
lbendlin
Super User
Super User

Date.ToText - PowerQuery M | Microsoft Learn

Make sure you format the text correctly. Ideally that should be in ISO-8601 format.

 

Your closing double quotes are in the wrong place too.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors