Lucasgrijander Posted January 2, 2006 Share Posted January 2, 2006 How can I convert "January 2, 2006" to "02/01/2006"? Link to comment Share on other sites More sharing options...
BigDod Posted January 2, 2006 Share Posted January 2, 2006 How can I convert "January 2, 2006" to "02/01/2006"?Lookup _DateTimeFormat in the help file. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 2, 2006 Moderators Share Posted January 2, 2006 I didn't see a convert to that type of date in the Date.au3 (of course there probably is one, and I snoozed right through it ), and this one will fail if the spaces aren't just right... But I'm too tired to fix it right <yawn> expandcollapse popup$DateToConvert = 'January 2, 2006' $MyDate = ConvertDate($DateToConvert) MsgBox(0, "", $MyDate) Func ConvertDate($DateToConvert) Local $Month[13] Local $NewDate Local $Add $Month[1] = "January" $Month[2] = "February" $Month[3] = "March" $Month[4] = "April" $Month[5] = "May" $Month[6] = "June" $Month[7] = "July" $Month[8] = "August" $Month[9] = "September" $Month[10] = "October" $Month[11] = "November" $Month[12] = "December" For $i = 1 To 12 If StringInStr($DateToConvert, $Month[$i]) Then $Trim = StringTrimLeft($DateToConvert, StringLen($Month[$i]) + 1) $Day = StringSplit($Trim, ',') $Year = StringRight($DateToConvert, 4) If $i > 9 Then If $Day[1] < 10 Then $Add = '0' $NewDate = $Add & $Day[1] & "/" & $i & "/" & $Year Return $NewDate Else If $Day[1] < 10 Then $Add = '0' $NewDate = $Add & $Day[1] & "/0" & $i & "/" & $Year Return $NewDate EndIf EndIf Next Return 0 EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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