|
|
|||||||
I'd like to present a couple of date manipulation routines and accept your praise for the wonderful algorithms. I'd like to, but I can't as they're not mine - I transliterated them from an article that I found on the web. Credit goes to Peter Baum whos document it is. The document can be found at: If you use the scripts please keep the reference to Peters document as per his request. You should also refer to this page to see the limitations of the algorithms - suffice to say that they should be fine for business use, but if you want to use them to calculate to first Tuesday of the Jurassic forget it. Now, the code. I keep these type of scripts in a "library" directory - you can of course copy them straight into a script and use them as subroutines if you prefer. There are two scripts, one to convert a calendar date into an internal integer representation (intdate.kix) and one to convert the internal representation back to the calendar format. code:; code:; As you can see the code is very small, and it executes very quickly. Just to show I'm not completely clueless, here are a couple of scripts which test the routines - you don't need any of these to use the routines, they here as examples. test_1.kix iterates the dates from 1 Jan 1900 'till 1 Jan 2001. It is a simple check that the results of the two routines complement each other. test_2.kix is more of a real world application. It'll accept a date, parse it and validate it. You can then apply a modifier. A positive number will advance the date, a negative one will reverse it. code:; If you want to use the test_2.kix script you will also need the strtok.kix script which I use to parse the date. code:; code:; Richard Howarth. [This message has been edited by rhowarth (edited 21 June 2000).] [This message has been edited by rhowarth (edited 21 June 2000).] |
||||||||
|
|
|||||||
Richard: This stuff is awesome ! I just tried it with some date subtraction (days between) type stuff, and it works like a champ. These are important algorithms for any date hound ! In fact, there must be some voo-doo or black magic embedded in these formulas (457 ? 153 ? ). My brain hurts just looking at them ! Thanks a cuzillion ! Jochen: I hate to say it, but I think you can throw in the towel now drat ! Shawn.
|
||||||||
|
|
|||||||
no way brother, i will built in richards stuff in my frame Gang, has anybody heard something from LD?!!? Jochen
|
||||||||
|
|
|||||||
Richard, WOW Jochen |
||||||||
|
|
|||||||
Combine these routines with the UDF capabilities of KIX2001 and what do you get? DateMath() and DateSerial() User-Defined Functions. Simply cut-and-paste them from: www.scriptlogic.com/support/kixtart/functionlib.asp |
||||||||
|
|
|||||||
Hello Richard, These are some very nice routines. However, could you possibly help me and perhaps others by posting a few samples to the board that are a little more clear for usage where you want to get a date difference of a file. Shawn, Bryce, JPOLS and some others already seem to know how to alter this code to their liking... I would like to learn. i.e. I want to find out if a file is older then a specific period of time. Meaning 10, 30, 60, etc.. days old. The date format returned by the files are similar to: 2001/05/28 18:00:00 but code that could decipher for YYYY/DD/MM, MM/DD/YYYY etc... would be great. Bryce and others have come up with these http://kixtart.org/board/Forum2/HTML/000334.html adamharris posted this (which works), but perhaps yours would be more bullet proof using the Math routines here. http://kixtart.org/board/Forum2/HTML/000133.html Sample of what I'm looking for an answer for code: TIA for any and all assistance and training from those more learned in the art...
[This message has been edited by NTDOC (edited 07 June 2001).] |
||||||||
|
|
|||||||
Richard, Any update yet? Still waiting I've been sitting here at my desktop pressing the F5 key now for 2 YEARS, still don't see an update. [ 04. April 2003, 23:25: Message edited by: NTDOC ] |
||||||||
|
|
|||||||
|
||||||||
|
|
|||||||
and finally DateCalc() (No dependencies) |
||||||||
|
|
|||||||
Jens and Jochen, thanks for the links. Not exactly what I meant, but I guess it will do. Was meaning maybe something a little more easier for beginners to use/learn i.e. laymans terms. Hey guys... seems we lost one of the UDFs. Did the author delete it or what? SerialDate() - Convert dates to numbers (and back) for the purpose of performing date http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000089;p= SERIALTIME() - Convert time to numbers (and back) for the purpose of performing time http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000039 DateTimeMath() - Calculates the difference between two date-time strings http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000326 DateTimeDiff() - Calculates the time difference between two date-times-groups http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000374 TimeDiff() - Calculates the time difference between two times http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000040 DeltaTime() - Calculates time differences up to 23:59:59:999 http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000011 DateCalc() - Calculates Days between or returns calculated Date (Days as modifier) http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000076 DateMath() FYI You have requested a topic that does not exist! http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000102#000000 |
||||||||
|
|
|||||||
Actually, DateMath() is available here: http://www.scriptlogic.com/kixtart/FunctionLibrary_ViewFunction.aspx?ID=DateMath |
||||||||
|
|
|||||||
While I was pondering Ent-like over an appropriate response these durned whipper-snappers came up with more user friendly UDFs than I could shake a wizened stick-like at. Spookily all those litle jobs that need doing around the house get delayed in a similar fashion. |
||||||||
|
|
|||||||
We Hobbits are way too fast for ya , eh ? |