Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
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

1 Solution

Accepted Solutions
Nicole-Smith

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

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

Not applicable
Author

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