7 Replies Latest reply: Apr 17, 2012 2:16 PM by swuehl RSS

    today button

    adibaba08

      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

        • Re: today button
          swuehl

          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?

            • Re: today button
              adibaba08

               

              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?

               

               

                • today button
                  swuehl

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

                   


              • today button
                Parag Patil

                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

                • Re: today button
                  Ashok Chandran

                  Hi

                   

                       Hope the attached file will be helpful for you

                   

                  Regards

                   

                  Ashok

                    • Re: today button
                      adibaba08

                      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

                        • Re: today button
                          swuehl

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