Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Output of Hour() function

Hi,

why am i getting the '0' value in vHour variable using Today() function?

1.jpg

2.jpg

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I don't think you need dollar sign expansion here (you would need it in a LOAD statement, not necessarily in control statements or LET variable assignment).

Let vToday = Now();

Let Hour = Hour(vToday);

vToday31.01.2017 20:09:10
vHour20

View solution in original post

10 Replies
Nicole-Smith

You need to use dollar sign expansion:

LET vToday = Today();

LET vHour = Hour($(vToday));

The vHour will still be equal to 0 because Today() uses 12:00 AM for its timestamp.  If you want the current timestamp, you'll want to use now():

LET vToday = Now();

LET vHour = Hour($(vToday));

Anonymous
Not applicable
Author

Hi Nicole,

Thank you for the quick reply but can you please specify why should i use Dollar sign expansion and I cannot see the hour value based on the day like Today?

sunny_talwar

Or just

LET vHour = Hour(Now())Today();

Anonymous
Not applicable
Author

Hi Sunny,

Your answer is still giving me 0 in vHour variable but in vToday variable it is giving me date and time.

Nicole-Smith

In the load script, you need to use dollar sign expansion to get the value in a variable.

As for the hour, Today() will return '2017-01-31 00:00:00.000' while Now() will return the timestamp of when it is called (i.e. '2017-01-31 10:49:03.386').

swuehl
MVP
MVP

I don't think you need dollar sign expansion here (you would need it in a LOAD statement, not necessarily in control statements or LET variable assignment).

Let vToday = Now();

Let Hour = Hour(vToday);

vToday31.01.2017 20:09:10
vHour20
sunny_talwar

Let vHour = Hour(Now()); is giving 0? Really?

Nicole-Smith

Good to know swuehl‌.  Thanks for the correction!

Anonymous
Not applicable
Author

Hi stefan,

Thank You so much for the information and your answer worked for me.