Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Lily
Contributor III
Contributor III

SQL error when converting the date format from yyyymmdd to dd/mm/yyyy

I'm having difficulty converting date format from yyyymmdd (e.g.: 20210515) to dd/mm/yyyy (e.g.: 15/05/2021) .

I tried several QV community sample scripts to convert the date but still unsuccessful. Here's an example load script that I tried:

i)  Date(Date#("ERDAT",'YYYYMMDD'),'MM/DD/YYYY') as "CreatedOnDateNew",
ii) Date(alt(Date#("ERDAT", 'YYYYMMDD')), 'DD/MM/YYYY') as "CreatedOnDateNew",

My load script: 

Load *;
SQL Select
"AUFNR" as "OrderNo",
"AUART" as "OrderType",
"WERKS" as "Plant",
"MTRLNO" as "MaterialNo",
"ERDAT" as "CreatedOnDate",
//Date(Date#("ERDAT",'YYYYMMDD'),'MM/DD/YYYY') as "NewCreatedOnDate",
Date(alt(Date#("ERDAT", 'YYYYMMDD')), 'DD/MM/YYYY') as "NewCreatedOnDate"
From "_SYS_BIC"."QV"
Group By "AUFNR",
"AUART",
"WERKS",
"MTRLNO",
"ERDAT";

However, I encountered an error when I trying to load the script as below:

SQL##f - SqlState: S1000, ErrorCode: 328, ErrorMsg: [SAP AG][LIBODBCHDB DLL][HDBODBC] General error;328 invalid name of function or procedure: DATE: line 24 col 3 (at pos 614)

Any Idea how can I resolve this?

 

Labels (1)
1 Solution

Accepted Solutions
vamsee
Specialist
Specialist

Try using the same date scripts in the load statement instead of the Select statement

Date(Date#(ERDAT,'YYYYMMDD'),'MM/DD/YYYY') as CreatedOnDateNew,

View solution in original post

2 Replies
vamsee
Specialist
Specialist

Try using the same date scripts in the load statement instead of the Select statement

Date(Date#(ERDAT,'YYYYMMDD'),'MM/DD/YYYY') as CreatedOnDateNew,
Lily
Contributor III
Contributor III
Author

I tried your suggestions and they worked perfectly. Thanks @vamsee 😄

Load 
*,
Date(Date#(CreatedOnDate,'YYYYMMDD'),'MM/DD/YYYY') as NewCreatedOnDate;
SQL Select
"AUFNR" as "OrderNo",
"AUART" as "OrderType",
"WERKS" as "Plant",
"MTRLNO" as "MaterialNo",
"ERDAT" as "CreatedOnDate"
From "_SYS_BIC"."QV"
Group By "AUFNR",
"AUART",
"WERKS",
"MTRLNO",
"ERDAT";