kiffab Posted July 28, 2011 Share Posted July 28, 2011 HiI'm connecting to a database, running a query and pulling a date back.Example:SELECT max(createddate) FROM table1In my AutoIt output I will see something like:201107282103I tried using the date convert in the SQL query, which works in Management Studio but not via AutoIt.Is there any way to convert this via AutoIt?Thanks Link to comment Share on other sites More sharing options...
smartee Posted July 28, 2011 Share Posted July 28, 2011 Use StringRegExp(), its fun Link to comment Share on other sites More sharing options...
sleepydvdr Posted July 28, 2011 Share Posted July 28, 2011 What format do you want to convert it to? This website lists a lot of possibilities: http://www.sql-server-helper.com/tips/date-formats.aspx #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
kiffab Posted July 28, 2011 Author Share Posted July 28, 2011 What format do you want to convert it to? This website lists a lot of possibilities:http://www.sql-server-helper.com/tips/date-formats.aspxI don't believe it.... I was on this exact page earlier trying the conversions and thought they werent working in AutoIt. I must've been doing something wrong as it worked in Management Studio. DOH!Tried again and bingo, it's working.Thanks Link to comment Share on other sites More sharing options...
sleepydvdr Posted July 28, 2011 Share Posted July 28, 2011 I don't believe it.... I was on this exact page earlier trying the conversions and thought they werent working in AutoIt. I must've been doing something wrong as it worked in Management Studio. DOH!Tried again and bingo, it's working.Thanks You weren't holding your tongue right. #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
Juvigy Posted August 1, 2011 Share Posted August 1, 2011 Local $String = "20110722141500" Local $DateTime = StringRegExpReplace($String, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "\1/\2/\3 \4:\5:\6") ConsoleWrite($String & " to " & $DateTime & @LF) $DateCalc = _DateDiff( 'n',$DateTime,_NowCalc()) ConsoleWrite($DateCalc & @CRLF) If converting from SQL is not an option (like excel/outlook for example). 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