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

How compare the actual date and time with a variable create in VB macro?

Hi all,

How compare the actual date and time with a variable create in VB macro?

I tried this code, but the result is always "exit" independing what my test time.

Sub testa_horario()

vDateAtual = now()

vDate = date()&" 11:00:00"

if vDateAtual > vDate then

msgbox("run macro II")

else

msgbox("exit")

End if

End sub

Thanks!

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

This should do it:

Sub testa_horario()

vDateAtual = Now()

vDate = cdate(date()&" 11:00:00")

if vDateAtual > vDate then

msgbox("run macro II")

else

msgbox("exit")

End if

End sub

View solution in original post

5 Replies
stigchel
Partner - Master
Partner - Master

To assign variables use Set (or Let) so:

Let vDateAtual = now()

stigchel
Partner - Master
Partner - Master

For the difference between Let and Set see e.g.

use of SET and LET in script

Not applicable
Author

Thank you, but I need create and compare the variables in a macro, no in the load script.

Anonymous
Not applicable
Author

This should do it:

Sub testa_horario()

vDateAtual = Now()

vDate = cdate(date()&" 11:00:00")

if vDateAtual > vDate then

msgbox("run macro II")

else

msgbox("exit")

End if

End sub

Not applicable
Author

It works! Thank you!