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

# Conversion of TimeStamp to Date #

Hi Folks,

Greeting for the day. I'm writing this post, not for asking any question. But, I feel it will be useful for those who struggles like me at their beginning stages. 

I read many posts and try to convert date variable has type timestamp to new date variable to type date. 

Yes, there are many folks already posted many posts which might help you, but this conversion will help you specially when you are planning to use date in the date filter, created using manubar date filter.

I suggest you can use the below mentioned formula to convert the date;

Date(Floor(Date(Date#(variablename, 'MM/DD/YYYY hh:mm:ss'),'MM/DD/YYYY')),'MM/DD/YYYY') as Date

Now the question arise whey I am using date function twice. Let me explain;

The first part "Date#(" will read the date from date source, in my case from Hive date stamp and convert to again timestamp but format will be 'MM/DD/YYYY' using "Date(Date#(" function.

The second part "Floor" which will extract only date part of the new date and the last function Date again convert date in display format 'MM/DD/YYYY'.

I hope this will help you.

Enjoy learning Qliksense.

Regards,

Sagar.

 

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Sagar, Thanks for sharing. Could you try removing the inner date() and see - if you get a different result? I believe you should get no different result. For me, it looks like that the inner date() is redundant. Just give a try and share what you see.

Date(Floor(Date#(variablename, 'MM/DD/YYYY hh:mm:ss')),'MM/DD/YYYY') as Date

View solution in original post

5 Replies
tresesco
MVP
MVP

Sagar, Thanks for sharing. Could you try removing the inner date() and see - if you get a different result? I believe you should get no different result. For me, it looks like that the inner date() is redundant. Just give a try and share what you see.

Date(Floor(Date#(variablename, 'MM/DD/YYYY hh:mm:ss')),'MM/DD/YYYY') as Date

Sagar082
Creator
Creator
Author

Hi Tresesco,

Greeting for the day. Thank you for your suggestion. Let me tell you, I had already tryout your solution, but it didn't work for me. 

Nevertheless, it may work for some other folks. It is all depend on the which version you are using and utilization of RAM.

I observe many time same code fell to give me result, which could give to other folk.

Still, appreciated your suggestion. Keep on suggesting, so something new will be learn.

Regards,

Sagar.

tresesco
MVP
MVP


@Sagar082 wrote:

...

Nevertheless, it may work for some other folks. It is all depend on the which version you are using and utilization of RAM.

 'Version' dependency is logical, however I have never experienced this anomaly with date() and I doubt if anybody else would have, because that's a basic function there from very long (if not since Qlik inception).

'RAM' dependency looks to be not logical to me. Anyway, you are using less number of functions by removing one function reducing load (though would be very very minimal) on RAM/CPU.

But you never know - there are things that happen beyond explanations, you must have faced.  

Sagar082
Creator
Creator
Author

Hi Tresesco,

Greeting for the day. Thanks for pointing out. I don't know, but somehow it worked. 

May be I mislead in syntax or something else.

By the way thanks for advise.

Regards,

Sagar.

tresesco
MVP
MVP


@Sagar082 wrote:

... I don't know, but somehow it worked. 


I would rather say 'somehow it didn't work' for you that time, because this is how it should work.