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: 
Samuelgomes
Contributor
Contributor

How to Convert Month Number to Month Name

 
I have the VER_MES field and the Content of this field is numeric and I need to convert it to the name of the Month.
How to do this? Here's how I'm extracting the information

LIB CONNECT TO [SIGAOFC];

[VER010]:
SELECT "VER_FILIAL" AS "%FILIAL",
"VER_PREFIX",
"VER_AGRUPA",
"VER_MES",
"VER_ANO",
"VER_PE",
"VER_VALOR",
"VER_QTDVEI",
"VER_CODFIL",
"VER_CODVEN",
"VER_CODMAR",
"VER_MODVEI",
"D_E_L_E_T_",
"R_E_C_N_O_",
"VER_XPERBR",
"VER_XPERPR",
"VER_XPEROU",
"VER_XPERDI",
"VER_XBRONZ",
"VER_XPRATA",
"VER_XOURO",
"VER_XDIAMA",
"VER_XDIAS"
FROM SIGAOFC.dbo.VER010;

exit script;

2 Solutions

Accepted Solutions
Vegar
MVP
MVP

Try one of the following

Month(date#(VER_MES, 'M')) as Month

Month (makedate (2000,VER_MES)) as Month

View solution in original post

Nicole-Smith

You are putting a Qlik function inside of your SQL code (and it's not a SQL function so it doesn't recognize it).  You'll need to use it as a preceding load for it to work:

[VER010]:
LOAD *,
MonthName(MakeDate(VER_ANO,VER_MES)) AS %Month;
SELECT
"VER_FILIAL" AS "%FILIAL",
"VER_PREFIX",
"VER_AGRUPA",
"VER_MES",
"VER_ANO",
"VER_PE",
"VER_VALOR",
"VER_QTDVEI",
"VER_CODFIL",
"VER_CODVEN",
"VER_CODMAR",
"VER_MODVEI",
"D_E_L_E_T_",
"R_E_C_N_O_",
"VER_XPERBR",
"VER_XPERPR",
"VER_XPEROU",
"VER_XPERDI",
"VER_XBRONZ",
"VER_XPRATA",
"VER_XOURO",
"VER_XDIAMA",
"VER_XDIAS"
FROM SIGAOFC.dbo.VER010;

View solution in original post

4 Replies
Vegar
MVP
MVP

Try one of the following

Month(date#(VER_MES, 'M')) as Month

Month (makedate (2000,VER_MES)) as Month

Samuelgomes
Contributor
Contributor
Author

return this error When using the Month (makedate (2000,VER_MES)) as Month or Month(date#(VER_MES, 'M')) as Month

ERROR [42000] 'makedate' is not a recognized built-in function name

[VER010]:

SELECT

"VER_FILIAL" AS "%FILIAL",

"VER_PREFIX",

"VER_AGRUPA",

Month (makedate (2000,VER_MES)) as Month,

"VER_ANO",

"VER_PE",

"VER_VALOR",

"VER_QTDVEI",

"VER_CODFIL",

"VER_CODVEN",

"VER_CODMAR",

"VER_MODVEI",

"D_E_L_E_T_",

"R_E_C_N_O_",

"VER_XPERBR",

"VER_XPERPR",

"VER_XPEROU",

"VER_XPERDI",

"VER_XBRONZ",

"VER_XPRATA",

"VER_XOURO",

"VER_XDIAMA",

"VER_XDIAS"

FROM SIGAOFC.dbo.VER010

Samuelgomes
Contributor
Contributor
Author

return this error When using the Month (makedate (2000,VER_MES)) as Month or Month(date#(VER_MES, 'M')) as Month

ERROR [42000] 'makedate' is not a recognized built-in function name

[VER010]:

SELECT

"VER_FILIAL" AS "%FILIAL",

"VER_PREFIX",

"VER_AGRUPA",

Month (makedate (2000,VER_MES)) as %Month,

"VER_ANO",

"VER_PE",

"VER_VALOR",

"VER_QTDVEI",

"VER_CODFIL",

"VER_CODVEN",

"VER_CODMAR",

"VER_MODVEI",

"D_E_L_E_T_",

"R_E_C_N_O_",

"VER_XPERBR",

"VER_XPERPR",

"VER_XPEROU",

"VER_XPERDI",

"VER_XBRONZ",

"VER_XPRATA",

"VER_XOURO",

"VER_XDIAMA",

"VER_XDIAS"

FROM SIGAOFC.dbo.VER010

Nicole-Smith

You are putting a Qlik function inside of your SQL code (and it's not a SQL function so it doesn't recognize it).  You'll need to use it as a preceding load for it to work:

[VER010]:
LOAD *,
MonthName(MakeDate(VER_ANO,VER_MES)) AS %Month;
SELECT
"VER_FILIAL" AS "%FILIAL",
"VER_PREFIX",
"VER_AGRUPA",
"VER_MES",
"VER_ANO",
"VER_PE",
"VER_VALOR",
"VER_QTDVEI",
"VER_CODFIL",
"VER_CODVEN",
"VER_CODMAR",
"VER_MODVEI",
"D_E_L_E_T_",
"R_E_C_N_O_",
"VER_XPERBR",
"VER_XPERPR",
"VER_XPEROU",
"VER_XPERDI",
"VER_XBRONZ",
"VER_XPRATA",
"VER_XOURO",
"VER_XDIAMA",
"VER_XDIAS"
FROM SIGAOFC.dbo.VER010;