seanhart Posted July 28, 2005 Share Posted July 28, 2005 (edited) Looking through the functions included in the <date.au3> the one thing that's missing is a function that takes a system date and returns a standard "calc" date. (like the reverse of _DateTimeFormat). Searching the forums didn't reveal anything either, so attached is my UDF to solve this.Syntax is:_DateCalc ("date" [, "date format" [, "time format"]])Parametersdate - Date in either system format or format provided (time is optional)date format - [optional] format of date, default is system formattime format - [optional] format of time, default is system formatReturn ValueSuccess: Date in format YYYY/MM/DD [HH:mm:ss]Failure: Returns "", @ERROR = 1 (bad date), @ERROR = 2 (bad time)Remarks If 2 digit year is given, 81 - 99 becomes 1981 - 1999, otherwise 2000 - 2080.If time is not given, no time is returned.If seconds are not included, 00 is addedAny date format is valid as long as a separator is provided, the exception being YYYYMMDD which is valid without a separator.System format refers to the date format in use by the current user, rather than the default system date format which may be different. This is the same as is returned by the _Now () function.Example_DateCalc ("3/4/2005 1:15:01 PM")Output = 2005/03/04 13:15:01 (assuming system format is M/d/yyyy)_DateCalc ("3.4.05 13:15", "d.m.yy", "HH:mm:ss")Output = 2005/04/03 13:15:00_DateCalc ("20051203", "YYYYMMDD")Output = 2005/12/03_DateCalc (_Now ())Output = _NowCalc () - this can be used as a verification testDateCalc.au3 Edited July 28, 2005 by seanhart dble 1 Link to comment Share on other sites More sharing options...
Jeemo Posted July 15, 2008 Share Posted July 15, 2008 /Blows dust off of the post I can't believe nobody else has commented on this. After a decent amount of searching in hopes of not having to code this myself, I came across this post. Unless I missed something, it's the only Date/Time calculation that I could find that converts values in arbitrary formats to the AutoIT format so that functions like DateAdd() will work on your otherwise "incompatible" formats. It's awesome! @seanhart, if you're still around, thanks a lot for this, and great job. The only criticism I have is that I got an error on two lines (28 and 30) for variables being re-declared. Simply commenting out these two lines did the trick, though. Jeemo An emoticon is worth a dozen words. Link to comment Share on other sites More sharing options...
VishnuNair Posted August 21, 2015 Share Posted August 21, 2015 Thanks a ton SeanHart and Jeemo. Link to comment Share on other sites More sharing options...
jchd Posted August 22, 2015 Share Posted August 22, 2015 Do you realize that:The thread is 10 year oldThe post you answered is 7 year oldIts author hasn't been online for 4 yearsPlease don't resurrect threads this old. 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now