Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

Macro using dates for SQL

ecdbertecdbert Member Posts: 21 Maven
Hi:
I'm trying to use a macro with date in an SQL statement but I'm getting an error from the SQL side. Here is part of the SQL statement: 
Declare @fDate date, @tdate date , @processingdate date, @lag int =%{lag}
SET @fDate =%{themonth}

error message is "Operand type clash: int is incompatible with date."

How do I resolve this?

Best Answer

  • ecdbertecdbert Member Posts: 21 Maven
    Solution Accepted
    UPDATE: I've resolved this by using 'concat' to add single quotes before and after the macro value in a 'Generate Macro' operator.

Answers

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Hi,

    that's a way to do it.

    You can also add the single quotes inside the SQL string if you are not using the prepare functionality.

    To make sure that you're not adding SQL injection vulnerabilities, you should use the "prepare statement" setting and enter your variable parameters in the form. Then RapidMiner will care for the correct quoting.

    Regards,
    Balázs
Sign In or Register to comment.