Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

today button

hello all,

i would like to add a button that will calculate the current date ? does any one have a simple macro for this?

thanks  alot

7 Replies
swuehl
MVP
MVP

Well, there are built-in QV functions to retrieve the current date and time:

now([ timer_mode])

Returns a timestamp of the current time from the system clock. The timer_mode may have the following values:

0 Time at script run
1 Time at function call
2 Time when the document was opened  

Default timer_mode is 1. The timer_mode = 1 should be used with caution, since it polls the operating system every second and hence could slow down the system.

today([timer_mode] )

Returns the current date from the system clock. The timer_mode may have the following values:

0 Date at script run
1 Date at function call
2 Date when the document was opened  

Default timer_mode is 2. The timer_mode = 1 should be used with caution, since it polls the operating system every second and hence could slow down the system.

So I am not sure why you want to use a macro for that, what do you want to do with the current date?

Anonymous
Not applicable
Author

I have a calendar in my model and I would like to a "TODAY" button that by pressing it the calendar will move/ show the current date I don’t see how I can do this with QV functions you mentioned above?

swuehl
MVP
MVP

I think it should be sufficient to create a button with action 'Selection' - 'Select in Field', then enter your field name (just the name, no equal sign etc) into the field entry box and as search expression

=today()


Not applicable
Author

Hi,

Use This Macro,

sub SetToToday()
dim thisYear, thisMonth, thisDay, datestamp
set v = ActiveDocument.Variables("vMaxDay")
set vToday = v.GetContent
set v2 = ActiveDocument.Variables("vMaxMonth")
set vMonth = v2.GetContent
thisYear = year(vToday.String)
thisMonth = vMonth.String
thisDay = day(vToday.String)
ActiveDocument.Fields("Day").Select thisDay
ActiveDocument.Fields("Year").Select thisYear
ActiveDocument.Fields("Month").Select thisMonth
end sub

Anonymous
Not applicable
Author

Hi

     Hope the attached file will be helpful for you

Regards

Ashok

Anonymous
Not applicable
Author

Thank alot It helped alot

How can I add a trigger so that each time u open the model the button will be pressed

And the current date will be shown ? Thanks again

B

swuehl
MVP
MVP

I think you don't need a macro for that, you can do all this with a selection - select in field action, see also attached.

But anyway, if you want to run the selection or macro action on opening of the document, just create an appropriate trigger in

document settings - triggers (see also attached).