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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
srihitha
Contributor III
Contributor III

Derived fields

Declare:

LOAD * INLINE [

EndDate

28/03/2015

10/12/2015

5/2/2016

31/3/2016

19/5/2016

15/9/2016

] ;


Calendar:
DECLARE FIELD DEFINITION TAGGED '$date'
Parameters
first_month_of_year = 1
Fields
Year($1) As Year Tagged ('$numeric'),
Month($1) as Month Tagged ('$numeric'),
Date($1) as Date Tagged ('$date'),
Week($1) as Week Tagged ('$numeric'),
Weekday($1) as Weekday Tagged ('$numeric'),
DayNumberOfYear($1, first_month_of_year) as DayNumberOfYear Tagged ('$numeric');

DERIVE FIELDS FROM FIELDS EndDate USING Calendar;

===========

Above code is generating derived fields only with below two date values when I used them in sheet.I want to know what happened to other four Enddate values and why they are not reflected in sheet.

EndDate.Calendar.Date

---------------------------------

10/12/2015

5/2/2016

 

 

Labels (4)
1 Solution

Accepted Solutions
MarcoWedel

How is your DateFormat variable defined?

Should be 'DD/MM/YYYY' to match your data, but maybe it's defined as 'MM/DD/YYYY', so the first numerical digits are interpreted as month, i.e. this only works for starting numbers <= 12.

In this case try changing your DateFormat variable in the script:

SET DateFormat='DD/MM/YYYY';

 

Or instead load EndDate using the Date#() interpretation function:

Declare:
LOAD Date#(EndDate,'DD/MM/YYYY') as EndDate
INLINE [
EndDate
28/03/2015
10/12/2015
5/2/2016
31/3/2016
19/5/2016
15/9/2016
];

 

hope this helps

Marco

View solution in original post

1 Reply
MarcoWedel

How is your DateFormat variable defined?

Should be 'DD/MM/YYYY' to match your data, but maybe it's defined as 'MM/DD/YYYY', so the first numerical digits are interpreted as month, i.e. this only works for starting numbers <= 12.

In this case try changing your DateFormat variable in the script:

SET DateFormat='DD/MM/YYYY';

 

Or instead load EndDate using the Date#() interpretation function:

Declare:
LOAD Date#(EndDate,'DD/MM/YYYY') as EndDate
INLINE [
EndDate
28/03/2015
10/12/2015
5/2/2016
31/3/2016
19/5/2016
15/9/2016
];

 

hope this helps

Marco