I have two date variables as FirstDate and EndDate
select * from tablename where columnname BETWEEN ‘01/01/2020’ AND ‘31/01/2020’
instead of these two date,I want to enter the two date variables in the above query.
can anyone help me with sql query which isto be used inside execute query activity
@rifnanahas Have you tried using the Expression in this way :
"select * from tablename where columnname BETWEEN “+FirstDate+” AND "+EndDate
when I tried this its showing an error in activity as "disallows implicit conversion from date to string
@rifnanahas Ok, What is the Datatype of Date in Datatable ?
@rifnanahas Sorry, I meant Database
@rifnanahas Is it possible for you to Convert Date type to String in Database?
No, I doesn’t have the right to convert
Maybe look into CAST?
I’m a little confused. If you need them to be strings then try something like:
CAST(TableName.EndDate AS varchar),
CAST(TableName.FirstDate AS varchar)
and if you need them as datetime then the same thing but datetime instead of varchar.
varQuery = "select * from tablename where columnname BETWEEN "+ FirstDate.ToString("dd/MM/yyyy") +" AND "+ EndDate.ToString("dd/MM/yyyy")
Create argument in parameters property of execute query activity and pass that parameters in query with @variablename.
Same as we do in procedure in SQL server