tommytx Posted November 4, 2012 Share Posted November 4, 2012 (edited) 1/1/2010 14:10 Can some one steer me in the direction to convert this sort of time date into something like: 01/01/2010 14:10 so that it can be added, subtracted, and/or compared.... This is what comes out of the XL spread sheet and I assume the spread sheet could deal with it, but I think I need to format it as above to get autoit to deal with it... just a point in the right direction would be a big help. I could use autoit to break it down like so: 1/ 1/ 2010 14:10 and if the length of the digit is less than 2 then add a zero on the left like 01/ and if its two digits just leave it alone.. but I am sure all your super smart folks already know of an existing script that will do if for me without me re-inventing the wheel.. Thanks! 1/1/2010 14:10 2/7/2010 14:24 12/15/2012 18:15 1/1/2012 18:15 7/23/2009 18:50 10/1/2010 19:19 Edited November 4, 2012 by tommytx Link to comment Share on other sites More sharing options...
Blue_Drache Posted November 4, 2012 Share Posted November 4, 2012 A regular expression would be the most efficient, but I don't speak the language. StringRegExp() Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2012 Moderators Share Posted November 4, 2012 tommytx,This is a job for StringSplit and StringFormat: $sInput = "1/1/2010 4:10" $aSplit_1 = StringSplit($sInput, " ") $aSplit_Day = StringSplit($aSplit_1[1], "/") $aSplit_Time = StringSplit($aSplit_1[2], ":") $sOutPut = StringFormat("%02i/%02i/%4i", $aSplit_Day[1], $aSplit_Day[2], $aSplit_Day[3]) & " " & StringFormat("%02i:%02i", $aSplit_Time[1], $aSplit_Time[2]) ConsoleWrite($sOutPut & @CRLF)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Malkey Posted November 5, 2012 Share Posted November 5, 2012 Another example. #include <Date.au3> Local $sInput = "10/31/2012 9:5" Local $TimeNow = _NowCalc() ; Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations. Local $aOutPut = StringRegExp($sInput, "(d{1,2})/(d{1,2})/(d{1,4})h*(d{1,2}):(d{1,2}):?(d{0,2})", 3) Local $sOutPutDate = StringFormat("%04i/%02i/%02i %02i:%02i:%02i", $aOutPut[2], $aOutPut[0], $aOutPut[1], $aOutPut[3], $aOutPut[4], $aOutPut[5]) Local $iDateCalcD = _DateDiff('D', $sOutPutDate, $TimeNow) Local $iDateCalch = _DateDiff('h', $sOutPutDate, $TimeNow) Local $iDateCalcm = _DateDiff('n', $sOutPutDate, $TimeNow) Local $iDateCalcS = _DateDiff('s', $sOutPutDate, $TimeNow) MsgBox(4096, "Time difference", StringFormat(" %19sn - %19sn = %i Days %2i hrs %2i min %2i sec", _ $TimeNow, $sOutPutDate, $iDateCalcD, Int($iDateCalch - $iDateCalcD * 24), Int($iDateCalcm - $iDateCalch * 60), Int($iDateCalcS - $iDateCalcm * 60))) Link to comment Share on other sites More sharing options...
AZJIO Posted November 5, 2012 Share Posted November 5, 2012 My other projects or all 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