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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to Get Month Number in Script


Team,

I'm loading an Excel file in the script, and have figured out how to add a Month field calculated from the date, but it shows month name and my other data is month number.  Is there a way to get the month number calculated from the date?  I'm thinking it's probably easy, but I can't find the exact syntax.

Load ABC as [ABC Dashes],
    
SHPD_QTY,
    
Date(SHPD_DT, 'M/D/YY') as [Ship Date],
    
YEAR(Date(SHPD_DT,'M/D/YY')) as [Ship Yr],
    
MONTH(Date(SHPD_DT,'M/D/YY')) as [Ship Mo],
     1001
as Site,
    
COUNTRY_CD,
    
TAC1_CITY,
     TAC1_STATE,
     TAC1_ZIP5 as [Zip Code]
FROM

(
ooxml, embedded labels, table is [ABC Shipments 2013];

Results in Jan, Feb, Mar, etc., but I am looking for 1,2,3,4,5,6,7,8,9,10,11,12..

Thanks,
Shelley

Labels (1)
1 Solution

Accepted Solutions
Nicole-Smith
MVP
MVP

Just wrap it in num().

Load ABC as [ABC Dashes],
    
SHPD_QTY,
    
Date(SHPD_DT, 'M/D/YY') as [Ship Date],
    
YEAR(Date(SHPD_DT,'M/D/YY')) as [Ship Yr],
     num(
MONTH(Date(SHPD_DT,'M/D/YY'))) as [Ship Mo],
     1001
as Site,
    
COUNTRY_CD,
    
TAC1_CITY,
     TAC1_STATE,
     TAC1_ZIP5 as [Zip Code]
FROM

(
ooxml, embedded labels, table is [ABC Shipments 2013];

View solution in original post

2 Replies
Nicole-Smith
MVP
MVP

Just wrap it in num().

Load ABC as [ABC Dashes],
    
SHPD_QTY,
    
Date(SHPD_DT, 'M/D/YY') as [Ship Date],
    
YEAR(Date(SHPD_DT,'M/D/YY')) as [Ship Yr],
     num(
MONTH(Date(SHPD_DT,'M/D/YY'))) as [Ship Mo],
     1001
as Site,
    
COUNTRY_CD,
    
TAC1_CITY,
     TAC1_STATE,
     TAC1_ZIP5 as [Zip Code]
FROM

(
ooxml, embedded labels, table is [ABC Shipments 2013];

Not applicable
Author

Man, you guys are awesome.  When will I ever have all this stuff figured out?!?!?  Thanks!