How to pass in a Variable in an Update query

I have a Scenario where I need to use an Update query to update a Date column in Database table and I am trying to find out if I can create a Variable for the Date Column and pass in Date conditions through variable.

For Example:
I want to set the Datetime as: DateTime.UtcNow.AddMinutes(1) so I want to pass this value through variable.

I tried Using Execute/ Execute non Query and passed in parameters and mentioned variable name as @variable or even ’”+VarDate+"’ but nothing worked. Either its throwing an error saying incorrect syntax near keyword where or declare the scalar variable
Below are some screenshots what I am trying to do:

Sorry if I read this wrong, but shouldn’t your UPDATE SQL be:

UPDATE 
dbo.CampaignBatch
SET
ProcessStatusTypeId=200,
YourDateColumn=@YourDateVariable
where 
CampaignBatchId in ('value')

?

Where is the column to which you are updating the date to?

2 Likes

Hi @achawla

From what @AndyMenon said think you can use like this,

"UPDATE dbo.CampaignBatch 
SET ProcessStatusTypeId=200,
YourDateColumn= "+Datetimevariable+"
where CampaignBatchId in ('357')"

You can convert the datetimevariable to string

And also remove the line breaks ,it should be in a single line.

Ex instead of using,

“Select
*
From table”

use

“Select * from table”

Thanks

1 Like

Thank you that helped me , I am new to UiPath so still learning :slight_smile:

1 Like

Thank you for the suggestion, this helped me.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.