Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
DestinedTale
Contributor II
Contributor II

Max (Month Year)

Hi,

i have a field in a  file 20190220080003 where i change the format of it from timestamp to MMM-YY in script.

When i want to display the months, it will show string 42826 instead of the format i want.

0~20190220080003~98853

let DateTimeStamp=Peek('DateTimeStamp', 0, 'LastLine');

let MonthYear=Date(Date#('01/'&mid($(DateTimeStamp),5,2)&'/'&Left($(DateTimeStamp),4)),'MMM-YY');

=[Month Year] = Apr 17

=max([Month Year]) = 42826

screenshot.PNG

Labels (2)
1 Solution

Accepted Solutions
Anil_Babu_Samineni

Try this?

Date(max([Month Year]),'MMM YY')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

3 Replies
Anil_Babu_Samineni

Try this?

Date(max([Month Year]),'MMM YY')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
passionate
Specialist
Specialist

these is number format for your date.

you can use date(max(timestamp),'MMM-YY')

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Others have pointed out that you will need the date() formatting function because max() returns a number.  I'd also suggest that you can get rid of the complex string parsing by reading the timestamp string with the TimeStamp#() function.

let DateTimeStamp=TimeStamp#(Peek('DateTimeStamp', 0, 'LastLine'),'YYYYMMDDhhmmss');

Then you have a proper Qlik timestamp and can use functions like 

let MonthYear MonthStart(DateTimeStamp);

-Rob