
PRO
dbeard
USA
Asked
— Edited
Can anyone point me in the direction to find a way to tell how much time there is between two dates.
For example Date1 = 10/29/2016 10:30:54 PM and Date2 = 10/28/2016 7:00:01 AM
How many days, hours, minutes, and seconds before date 1.
You'd need to break down the days and time separately then subtract. Have you got a script example you are working on?
@Dbeard,
EZ-Script has a few limitations and some parser bugs.
If you are doing complex or repetitive calculations, I would invest my time in a Plugin.
c# version:
output:
Thanks, ptp. I appreciate the code, not sure my skills are up to coding a plugin. I have trouble manipulating a date. I will start reviewing the plugin documentation and tutorial to see if I can figure it out.
@dbeard,
fixed a bug and added comments to explain my logic.
[feature] DateTime Functions MinDate() MaxDate() MonthName() AddDays() AddMonths() AddYears() AddHours() AddMinute() AddSeconds() FmtNum()
Casting Functions These functions are to cast objects from one datatype to another To Double: CDBL() To Integer: CInt() To Long: CLong() To Unsigned Integer: CUint() To Unsigned Long: CULong() To DateTime: CDateTime() [/feature]
@DJ,
That's a major refactoring! I tried that before but does not work as the OP wants. does not handle days, months, years.
Check the output:
Your code is very fun and impressive! You could save a bit of code by parsing the output of this...
The $diff in this case is 884.22:57:58. That's
I just added a fmttimespan() to EZ-Script for the next release. It will allow formatting of a timespan (which is what a datetime subtraction/addition creates)
@DJ,
yes it was more an exercise i can't do that in my day job
I like to test concepts: Goto / Return (like a function call) Working with an array to minimize variable usage Reusing a (function call)
everything went well.
yes i could parse the big number (days), but i would need to calculate the leap years, to extract years, then how many leap years in between, so i decided to do it from scratch.