and more in a single search tool across platforms. Read the announcement here. |
10/10/2023 01:51 AM - edited 10/10/2023 01:52 AM
Hi ,
we have a usecase where the data from source is coming in DD/MM/YYYY format and convert this into MM/DD/YYYY format
While trying this in preprocessor query we are facing synatx error
Preprocessor query:
{ "ADDITIONALTABLES": {"USERS": "SELECT USERKEY FROM USERS"},"COMPUTEDCOLUMNS": ["customproperty20"],"PREPROCESSQUERIES": ["UPDATE NEWUSERDATA SET CUSTOMPROPERTY20 ='DEVusers'","UPDATE NEWUSERDATA SET startdate = select DATE_FORMAT(NEWUSERDATA.startdate, '%m/%d/%Y') from currentusers where currentusers.systemusername=newuserdata.systemusername","UPDATE NEWUSERDATA SET enddate = select DATE_FORMAT(NEWUSERDATA.enddate, '%m/%d/%Y') from currentusers where currentusers.systemusername=newuserdata.systemusername"]}
please suggest what shall be the correct syntax
Regards,
Abdul Gaffar
Solved! Go to Solution.
10/10/2023 04:05 AM
Hello @Abdul_Gaffar,
Please try using this
UPDATE NEWUSERDATA SET startdate = select DATE_FORMAT(startdate, '%m/%d/%Y')
Thanks
10/10/2023 04:43 AM
10/10/2023 08:16 AM
Hello @Abdul_Gaffar,
I can see all possible checks are done. Next Step would be You need to see the logs when error is observed to know what is missing.
Thanks.
10/10/2023 08:23 AM
Hi @sudeshjaiswal ,
The following is the error
You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server
version for the right syntax to use near 'select
DATE_FORMAT(startdate, '%m/%d/%Y')' at line 1
Preprocessor query:
UPDATE NEWUSERDATA SET startdate = select DATE_FORMAT(startdate, '%m/%d/%Y')
Regards
Abdul gaffar
10/10/2023 11:32 AM
@Abdul_Gaffar : Try below
UPDATE NEWUSERDATA NU SET NU.startdate = DATE_FORMAT(NU.startdate, '%m/%d/%Y')
10/10/2023 08:38 AM - edited 10/10/2023 10:21 AM
Hello @Abdul_Gaffar,
Can you please try with the below query,
UPDATE NEWUSERDATA SET startdate = DATE_FORMAT(startdate, '%m/%d/%Y')
Thanks
10/11/2023 12:32 AM
Hi @sk ,
I have tried as per your specification
Facing error as " Error while processing
data: Data truncation: Incorrect datetime value:
'03-04-2021'"
Any suggestions to replicate
Regards
Abdul Gaffar
10/12/2023 01:44 AM
Hello @Abdul_Gaffar,
Can you please share the full json with the above changes.
Thanks.
10/12/2023 03:11 AM
Below is the modify user data json :
{"ADDITIONALTABLES": {"USERS": "SELECT USERKEY,startdate,enddate,systemusername FROM USERS"},"COMPUTEDCOLUMNS": ["customproperty20","startdate","enddate"],"PREPROCESSQUERIES": ["UPDATE NEWUSERDATA SET CUSTOMPROPERTY20 ='DEVusers'","UPDATE NEWUSERDATA NU SET NU.startdate = DATE_FORMAT(NU.startdate, '%m/%d/%Y')","UPDATE NEWUSERDATA NU SET NU.startdate = DATE_FORMAT(NU.enddate, '%m/%d/%Y')"]}
Regards
Abdul Gaffar
10/12/2023 05:45 AM
Hello @AbdulGaffar,
First, in your userimport JSON, map the values for 'startdate' and 'enddate' that you are fetching from your data source into custom properties, namely 'customproperty1' and 'customproperty2'. These custom properties will store the date values in the DD/MM/YYYY format. Then, in the preprocessor, set 'startdate' and 'enddate' as shown below:
{
"ADDITIONALTABLES": {
"USERS": "SELECT USERKEY, customproperty1 AS startdate, customproperty2 AS enddate, systemusername FROM USERS"
},
"COMPUTEDCOLUMNS": ["customproperty20", "startdate", "enddate"],
"PREPROCESSQUERIES": [
"UPDATE NEWUSERDATA SET CUSTOMPROPERTY20 = 'DEVusers'",
"UPDATE NEWUSERDATA NU SET NU.startdate = DATE_FORMAT(STR_TO_DATE(NU.customproperty1, '%d/%m/%Y'), '%Y-%m-%d')",
"UPDATE NEWUSERDATA NU SET NU.enddate = DATE_FORMAT(STR_TO_DATE(NU.customproperty2, '%d/%m/%Y'), '%Y-%m-%d')"
]
}
```
Please note that setting 'startdate' and 'enddate' will always be in the "yyyy-mm-dd" format, as these are in datetime type columns. Other formats will not be accepted.
Thanks