Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Create Variable with Date and Time

Hello,

I have the following variable:

LET vYEAR = YEAR(TODAY())-3;              // vYEAR = 2014

What I need is to create 2 more variables with the following values:

vSTART = 20150701 06:00:00 hs              // 1st day of july at 6 am from vYEAR+1

vEND = 20171001 06:00:00 hs                    // 1st day of current month at 6 am from current year

(*) Date format: YYYYMMDD hh:mm:ss

Do you know how could I get those values to use them in variables?

Thank you!

1 Solution

Accepted Solutions
maxgro
MVP
MVP

another one

LET vYEAR = YEAR(TODAY())-3;              // vYEAR = 2014

LET vSTART = Date(Makedate(vYEAR+1, 7) + 6/24, 'YYYYMMDD hh:mm:ss');

LET vEND = Date(MonthStart(Today()) + 6/24, 'YYYYMMDD hh:mm:ss');

1.png

View solution in original post

4 Replies
oscar_ortiz
Partner - Specialist
Partner - Specialist

Maybe something like this:

LET vStart = Date( YearStart( MakeDate(2014) ) , 'YYYYMMDD')  & ' 06:00:00 hs'

LET vEnd = Date( MonthStart( today() ), 'YYYYMMDD' ) & ' 06:00:00 hs'


Good luck

Oscar

oscar_ortiz
Partner - Specialist
Partner - Specialist

or

LET vStart = Date( YearStart( MakeDate(2014) ) , 'YYYYMMDD')  & ' ' & MakeTime( 6,0,0 )

LET vEnd = Date( MonthStart( today() ), 'YYYYMMDD' ) & ' ' & MakeTime( 6,0,0 )

Thanks

Oscar

antoniotiman
Master III
Master III

May be this

SET DateFormat='YYYYMMDD';
SET TimestampFormat='YYYYMMDD hh:mm:ss[.fff]';
LET vSTART = TimeStamp('20150701 06:00:00')&' hs';
LET vEND = Timestamp(MonthStart(Today
())&' '&'06:00:00')&' hs';

maxgro
MVP
MVP

another one

LET vYEAR = YEAR(TODAY())-3;              // vYEAR = 2014

LET vSTART = Date(Makedate(vYEAR+1, 7) + 6/24, 'YYYYMMDD hh:mm:ss');

LET vEND = Date(MonthStart(Today()) + 6/24, 'YYYYMMDD hh:mm:ss');

1.png