Jump to content
Macro Express Forums

how to set up Variable modify Date/time


Recommended Posts

I need some assistance. I am trying to set up a macro without using mouse moves.  The page I am working on has a date box that I need to change the date in it to display 20 days before the current date. In other words, if today's date was 06/28/2024, I need the date in the box to be 06/20/2024.  Or if today's date is 07/02/2024, I need it to be 06/13/2024. Since this will be run every day or so, I need to subtract 20 days from whatever the current date may be. I do not understand how to do this.  Can someone hopefully explain it to me, in layman's terms?

 

Link to comment
Share on other sites

It is simple. Create a Date/Time variable with the option to set it to now. Then modify the variable to subtract 20 days. Then output it in whatever format you please. See attached sample. 

DateSubDemo.mex

Link to comment
Share on other sites

Thank you for the info.  The download will not download and open properly.  It may be due to it being a .MEX file.  All my files are .MXE files. Just a guess. I did realize what you may have been trying to send me.  I found a "date time math" macro in the samples.mex folder on Macro Express.  But still not sure what I am looking at.  I have wrote a few small macros, but never anything where I have variables that I had to put in. The person that helped with more detailed macros has passed and so I am scrambling to learn. right now I feel like a deer in headlights. :)  I do know about having a ASCII file to begin some of my macros. Not sure if this is what I need to set up this variable. 

Your patience and help is greatly appreciated.

Link to comment
Share on other sites

All macros are in an file. The normal being an MEX file. Look at the left side of the macro explorer under Categories. Second button. Open Macro File. This will add it to the tree on the left. I didn't include an activation, so just run it manually from there or the debugger in the scripting editor. 

There is only date time. They are actually decimal variables with a value of one for a day. So 0.5 is 12 hours.

20 days ago was not midnight, it was this time of day. So you would either need to round, or simply don't output the time portion. Use the Variable Modify Date/Time > Convert to text variable, choose your desired format and destination variable. Now output that. 

See attached file where I added the command to my sample I made for you.
I hope this helps. 

DateSubDemo2.mex

Link to comment
Share on other sites

You may not need to use a Date variable. A Text variable works for me...

 

Date/Time: Set %TodayMinus20Days% to an adjusted date/time using "dd/mm/yyyy" as the format
Text Type (Simulate Keystrokes): %TodayMinus20Days%

<DATE/TIME Format="dd/mm/yyyy" Flags="\xB2" Date="30-Dec-1899" Day_Offset="-20" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%TodayMinus20Days%" IsDateVar="FALSE"/>
<TEXT TYPE Action="0" Text="%TodayMinus20Days%"/>

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...