vick Posted July 13, 2017 Share Posted July 13, 2017 HI, i have string like " Jun 13, 2017 14:11" format and i need to convert ind ate format so i can filter last 30 days etc. how i can achieve it? pl Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2017 Moderators Share Posted July 13, 2017 vick, My Date_Time_Convert UDF (look in my sig below for the link) will convert that string to any date format you require. 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...
vick Posted July 13, 2017 Author Share Posted July 13, 2017 Hi M23, thanks for quick reply. i tried your UDF below way but not worked. $sIn_Date = "Aug 01, 2013 6:30" $sOut_Date = _Date_Time_Convert($sIn_Date, "MMM dd, yyyy hh:mm", "mm/dd/yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) can you tell me where i am wrong pls? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2017 Moderators Share Posted July 13, 2017 vick, Looking at the code you posted, I see that the UDF returns @error 1 and @extended 8, which the UDF header tells me is "Only 12 hr hour format and no AM/PM set". So you need to define the time more closely - like this: #include "DTC.au3" #include <MsgBoxConstants.au3> $sIn_Date = "Aug 01, 2013 06:30" $sOut_Date = _Date_Time_Convert($sIn_Date, "MMM dd, yyyy HH:mm", "MM/dd/yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) Note you also need to correctly code the required output string: "mm" gives you minutes, not months. 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...
mikell Posted July 13, 2017 Share Posted July 13, 2017 Melba's solution is the best, but if you get the string in 6:30 format instead of the 06:30 correct one, you might try this workaround Local $aMon_Short_In[13] = [12, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] Local $sIn_Date = "Aug 01, 2013 6:30" $tmp = $sIn_Date For $i = 1 to $aMon_Short_In[0] $tmp = StringReplace($tmp, $aMon_Short_In[$i], StringFormat("%02i", $i) ) Next $sOut_Date = StringRegExpReplace($tmp, '(\d\d)\h(\d\d),\h(\d{4}).*', "$1/$2/$3") MsgBox(0, "", $sIn_Date & @CRLF & $sOut_Date) Link to comment Share on other sites More sharing options...
vick Posted July 14, 2017 Author Share Posted July 14, 2017 Hello Melba, thanks for your help! it works now . 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