Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
aniruddhyadutta
Creator
Creator

Unable to calculate Max date

Hi All,

it seems a very simple issue but unable to resolve

I have a 'DATETIME' field in my table whose format is 'MMDDYYYYHHMMSS'

I just want to calculate the max date .

Last_Updated_Date:

Load

  Max (DATETIME)as MaxDate

  Resident  MasterData;

let last_Updated_Date= Peek('MaxDate',0,'Last_Updated_Date');


But MaxDate is returning as below  

1.PNG




its treating DATETIME as string i suppose..how to convert it to date?

cheers

AD




8 Replies
sunny_talwar

May be help QlikView understand your DATETIME field

MasterData

LOAD TimeStamp#(DATETIME, 'MMDDYYYYhhmmss') as DATETIME,

          ....

FROM ....

Last_Updated_Date:

Load

  Max (DATETIME)as MaxDate

  Resident  MasterData;

let last_Updated_Date= Peek('MaxDate',0,'Last_Updated_Date');

aniruddhyadutta
Creator
Creator
Author

Hi Sunny,

Thanks for your reply.I will obviously go through the post as you have mentioned.

but as of now I am getting the below values you have suggested like below

2.PNG

the DATETIME filed as you  see I have sorted numerically and the expected Max date should be 12092016002920.

here I am assuming the DATETIME field is in timestamp format in database but I now suspect it might be string.so do i need to convert it to timestamp?

sunny_talwar

Max? That seems like a min to me?

Capture.PNG

Gysbert_Wassenaar

12092016002920

That still looks like a text string (since it's left aligned in the filter pane). Perhaps you need to use the timestamp# function to turn it into a date value:

Timestamp(Timestamp#(DATETIME,'MMDDYYYYhhmmss'),'MM/DD/YYYY hh:mm:ss') as DATETIME


talk is cheap, supply exceeds demand
aniruddhyadutta
Creator
Creator
Author

Hi Sunny and gysbert ,

I am sorry I given the min screenshot earlier.

Thats what I originally suspected.

Now I have converted the datetime field as time stamp and they are right aligned.

need to do the max correctly now.

4.PNG

sunny_talwar

This should work not (using new DATETIME)

Last_Updated_Date:

Load

  Max (DATETIME)as MaxDate

  Resident  MasterData;

let last_Updated_Date= Peek('MaxDate',0,'Last_Updated_Date');

Shubham_Deshmukh
Specialist
Specialist

Hi Gysbert,

This is not working for me, dont know why...

I am taking max of Timestamp(Timestamp#(DATETIME,'MMDDYYYYhhmmss'),'MM/DD/YYYY hh:mm:ss') as DATETIME

Given format - MMM DD YYYY hh:mm:ss:fff TT

Required format - MM-DD-YYYY hh:mm:ss

Rgds,

Shubham