Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

shivalid
New Contributor III

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
MVP
MVP

Re: Output of Hour() function

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

Re: Output of Hour() function

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));

shivalid
New Contributor III

Re: Output of Hour() function

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?

Re: Output of Hour() function

Or just

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

shivalid
New Contributor III

Re: Output of Hour() function

Hi Sunny,

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

Re: Output of Hour() function

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').

MVP
MVP

Re: Output of Hour() function

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

Re: Output of Hour() function

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

Re: Output of Hour() function

Good to know swuehl‌.  Thanks for the correction!

shivalid
New Contributor III

Re: Output of Hour() function

Hi stefan,

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