The eccoMAGIC Forums
http://forums.eccoMAGIC.com/forum/YaBB.pl
the SLANG EXTENSION and Guest Programming >> Slangmgh: Questions, Suggestions, Requests >> Easy way to add / subtract hours (like "today()+X" for days)
http://forums.eccoMAGIC.com/forum/YaBB.pl?num=1201939776

Message started by Philster on 02/02/08 at 02:09:36

Title: Easy way to add / subtract hours (like "today()+X" for days)
Post by Philster on 02/02/08 at 02:09:36

Say, "now()+5h" would add 5 hours to the current time, also changing the date if it goes beyond midnight / new year etc. Subtracting should work the same way.

I know this can probably be done through string manipulation in some way, but I'm sure that would be rather complicated.

If anyone already has a script / expression that does this, could you please post it?

Many thanks

Phil

Title: Re: Easy way to add / subtract hours (like "today()+X" for days)
Post by Admin on 02/02/08 at 16:31:59

check out the eccoWiki on the date expressions.

i think you can do it easily that way.


Title: Re: Easy way to add / subtract hours (like "today()+X" for days)
Post by Philster on 02/04/08 at 08:39:34

Thanks for your reply.

If you mean the below, it only goes down to the day level, so does not include hours. If you had something else in mind could you please be more specific / post a URL within the Wiki? Thanks. Phil

Relative date expression may be used to calulate a date in the future

   * +(-)xd plus or minus "x" days (eg. +5d, -27d)
   * +(-)xw plus or minus "x" weeks
   * +(-)xm plus or minus "x" months
   * +(-)xy plus or minus "x" years
   * -2y9m 6w2d (calculates from "today")

Title: Re: Easy way to add / subtract hours (like "today()+X" for days)
Post by Admin on 02/04/08 at 15:21:51


ok,

isolate the time portion of the date  (if any)

200610020920


add the desired amount of time to it,

if is > 2400 then add 1 to date,
otherwise just make date equal to new value.



this is doable even as a simple rule,  actually.


The eccoMAGIC Forums » Powered by YaBB 2.1!
YaBB © 2000-2005. All Rights Reserved.