Jump to content
Macro Express Forums

Documentation working with time/date variables & calculations

Recommended Posts

Have not used MEP for some time. Need to find documentation on working with time/date variables & calculation  with Run Macro in Variable.  I have downloaded Macro Express User Macro - Date String to DateTime Variable (macros.com)  But can't modify if for want I want to do. Googled & did not find much discussing how to use these.


What I need to do is to use text file process to capture dates & times. This is not a problem. The lines to capture are of a general format like:

Saturday, November 21, 2020  1:10 AM.


The problem is that these are stamped based on GMT  and I am GMT + 8.

I am wanting to correct the times to my time & adjust the date when necessary.  If I can learn how to do it, MEP will do it correctly.

Can anyone point me in the right direction?  I could find almost no examples using for doing similar things. Also very little on hours/minutes as opposed to dates.


I noticed that if I copy the above macro directly into a blank macro, I have to redeclare the text variables when I run it, but I could not get dtResult declared correctly.

Any help would be appreciated.,



Link to comment
Share on other sites

Check the Help file. 

Variable Modify Date/Time. In the lower right you can choose to add an amount. So you can add 8 and select the Hour option in the dropdown. If you need to subtract, add a negative. 

Are you're sure you're UTC +8? If you're like me on the west cost of the USA, it's UTC -8 for PST. 


Link to comment
Share on other sites

Thanks for the prompt response Cory. You are correct I am UTC -8.  I can get the data from the text file into variables & manipulate as integer or string variables without problems. My problem is that I do not know how to  convert the string variables into into dtVariables including hours & minutes. The example sited above does the dates but not hours & minutes.


Link to comment
Share on other sites

There's no magic way to cast a date string to Date/Time. First I'd like to let you know dates are at the core level decimals. 1 = 1 day starting 1/1/1900. But you can also build a date using the method I Described above. Add years, months, days and so forth. Or you can create the values then cast them. First you should parse the string, I'm guessing using the spaces. Remove the commas. A 'Select Case' for the months. January = 1  month. Look at the Split command. That's how I'd start it. 

However you could also do the math. That so many hours and minutes are fractions of a day. So if the hour is 12, then 12/24 = .5. You can build a decimal this way then create the DateTime variable by converting from decimal. 

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.

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.

  • Create New...