Sign in to follow this  
Followers 0
asdofasdas

Calculating in time

3 posts in this topic

#1 ·  Posted (edited)

So let's say I have a time string like '23.05.2011 11:39' (or what's the best format they come in). How can I add 33 hours and 33 minutes to this string? And then how do I compare these strings, which is bigger/larger/later?

Just looking for some direction to know which functions to work with. Thank you!

Edited by asdofasdas

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

So let's say I have a time string like '23.05.2011 11:39' (or what's the best format they come in). How can I add 33 hours and 33 minutes to this string? And then how do I compare these strings, which is bigger/larger/later?

Just looking for some direction to know which functions to work with. Thank you!

Hi,

take a look at _DateAdd and _DateDiff in the helpfile.

Example:

#include <date.au3>
$olddate = '2011/05/23 11:39' ; As it has to have the format YYYY/MM/DD HH:MM:SS
$newdate = _DateAdd("n", 33 * 60 + 33, $olddate)
$difdate = _DateDiff($newdate, $olddate)

Edit: added forgotten include.

Edited by Hannes123

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

MM/DD/YYYY is a terrible format for date strings as they don't sort correctly and most library calls you find around (AutoIt or not) will require ISO 8601 or a compatible subset of (like YYYY-MM-DD) for dates/times in string format. Changing the separator slash from/to hyphen is straightforward.

Formats significantly departing from ISO8601 should be only used for user display but never for storage or computation.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0