Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

adibaba08
New Contributor II

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

Re: today button

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?

adibaba08
New Contributor II

Re: today button

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?

MVP
MVP

today button

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

today button

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

chandashok
Contributor III

Re: today button

Hi

     Hope the attached file will be helpful for you

Regards

Ashok

adibaba08
New Contributor II

Re: today button

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

MVP
MVP

Re: today button

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

Community Browser