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: 
Not applicable

How to insert new field as Months Name based on Date?

I want to insert another field as Month and it should contain only month names based on dates given in Date of Sales field. And this [Date of Sales] filed in MM/DD/YYYY format.

How to insert this field. Please any one help me.

[Case Study 3]:

LOAD Customer_id as [Customer ID],

     Customer_name as [Customer Name],

     Subsegment,

     City,

     Division,

     Category,

     Version,

     Sales_amount as [Sales],

     No_of_Licences as [Licenses],

    Sales_Date as [Date of Sales]

  

  FROM

Sales1.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

1 Solution

Accepted Solutions
its_anandrjs
Champion III
Champion III

For date of sale try this     


Date(Date#(Sales_Date,'MM/DD/YYYY'),'MM/DD/YYYY') as [Date of Sales],

[Case Study 3]:

LOAD Customer_id as [Customer ID],

     Customer_name as [Customer Name],

     Subsegment,

     City,

     Division,

     Category,

     Version,

     Sales_amount as [Sales],

     No_of_Licences as [Licenses],

     Date(Date#(Sales_Date,'MM/DD/YYYY'),'MM/DD/YYYY') as [Date of Sales],


     Month(Sales_Date) as [Sales Month]  //Check this

     FROM

Sales1.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

View solution in original post

12 Replies
sundarakumar
Specialist II
Specialist II

[Case Study 3]:

LOAD Customer_id as [Customer ID],

     Customer_name as [Customer Name],

     Subsegment,

     City,

     Division,

     Category,

     Version,

     Sales_amount as [Sales],

     No_of_Licences as [Licenses],

    Sales_Date as [Date of Sales],

month(Sales_Date) as month

  

  FROM

Sales1.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

its_anandrjs
Champion III
Champion III

Updated new script check now

Load your table like and add the MM/DD/YYYY format for date field

[Case Study 3]:

LOAD Customer_id as [Customer ID],

     Customer_name as [Customer Name],

     Subsegment,

     City,

     Division,

     Category,

     Version,

     Sales_amount as [Sales],

     No_of_Licences as [Licenses],

     Sales_Date as [Date of Sales],

     Monthname(Sales_Date) as MonthName,  //Check this

     Month(Sales_Date) as [Sales Month]  //Check this

     FROM

Sales1.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

nizamsha
Specialist II
Specialist II

[Case Study 3]:

LOAD Customer_id as [Customer ID],

     Customer_name as [Customer Name],

     Subsegment,

     City,

     Division,

     Category,

     Version,

     Sales_amount as [Sales],

     No_of_Licences as [Licenses],

    Sales_Date as [Date of Sales],

  Date( Sales_Date,'MMM') as SaleMonth

  FROM

Sales1.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

MK_QSL
MVP
MVP

You can simply add below line in your script...

Month(YourDateField) as Month

But better to create a master calendar..

Master Calendar Generation Script

Not applicable
Author

thanks for ur replies, its not working... for better understanding i m attaching the date list box. I just want to add another list box with months name according to given dates. Capture.JPG.jpg

please help and thanks in advance

its_anandrjs
Champion III
Champion III

Please check your date is not in date format it is text format thats why you are not able to get Months.

Try to connect it with any master calender. Otherwise please provide sample app.

kushalthakral
Creator III
Creator III

Hi Sandeep

Simply use

Month('Date') as Month,

Ex: Month('02/28/2014') as Month,

You will get FEB as Output.

Regards

Kushal Thakral

its_anandrjs
Champion III
Champion III

For date of sale try this     


Date(Date#(Sales_Date,'MM/DD/YYYY'),'MM/DD/YYYY') as [Date of Sales],

[Case Study 3]:

LOAD Customer_id as [Customer ID],

     Customer_name as [Customer Name],

     Subsegment,

     City,

     Division,

     Category,

     Version,

     Sales_amount as [Sales],

     No_of_Licences as [Licenses],

     Date(Date#(Sales_Date,'MM/DD/YYYY'),'MM/DD/YYYY') as [Date of Sales],


     Month(Sales_Date) as [Sales Month]  //Check this

     FROM

Sales1.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

sundarakumar
Specialist II
Specialist II

pls put the screen shot after loading it as

date(Sales_Date) as date_of_sales.

It the data is left aligned it is text, if it is right aligned it is numeric which is data.

-Sundar