Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Tags (1)
1 Solution

Accepted Solutions

Re: How to Get Month Number in Script

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];

2 Replies

Re: How to Get Month Number in Script

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

Re: How to Get Month Number in Script

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

Community Browser