wutzke Posted November 23, 2006 Share Posted November 23, 2006 How would you convert 09/25/2006 to Sep 25, 06 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 23, 2006 Share Posted November 23, 2006 How would you convert 09/25/2006 to Sep 25, 06 There have been MANY UDFs written for date formatting, so a little searching may turn up more elegant answers, but: You could split the string up by StringSplit(), using the forward slash as the delimiter, then convert each of the three parts to the desired format. Do you do arrays yet? Arrays will give you everything you need. The following code splits the original to parts in an array called $DateSplit: $DateIn = "09/25/2006" $DateSplit = StringSplit($DateIn, "/") Now the contents of that array are: $DateSplit[0] = 3 ; Count $DateSplit[1] = "09" $DateSplit[2] = "25" $DateSplit[3] = "2006" Hope that helps. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
wutzke Posted November 23, 2006 Author Share Posted November 23, 2006 Thanks so perhaps ... Global $A_Mon[13] = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] $DateIn = "09/25/2006" $DateSplit = StringSplit($DateIn, "/") $theMonthNum=$DateSplit[1] $theMonth=$A_Mon[$DateSplit[1]] $theYear=StringRight($DateSplit[3],2) $newdate = $theMonth & " " & $DateSplit[2] & ", " & $theYear could be a way the convert a date put into the datein var Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted November 23, 2006 Share Posted November 23, 2006 Thanks so perhaps ... Global $A_Mon[13] = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] $DateIn = "09/25/2006" $DateSplit = StringSplit($DateIn, "/") $theMonthNum=$DateSplit[1] $theMonth=$A_Mon[$DateSplit[1]] $theYear=StringRight($DateSplit[3],2) $newdate = $theMonth & " " & $DateSplit[2] & ", " & $theYear could be a way the convert a date put into the datein var yeah looks good to me Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 23, 2006 Moderators Share Posted November 23, 2006 $sDateIn = _DateToString("09/25/2006") MsgBox(64, 'Info', $sDateIn) Func _DateToString($sDate) Local $aMon[13] = ['','Jan','Feb','March','April','May','June','July','Aug','Sep','Oct','Nov','Dec'] Local $aDate = StringRegExp($sDate, '^(\d{1,2})/(\d{1,2})/(\d{2}|\d{4})$', 1) If IsArray($aDate) Then Return $aMon[Int($aDate[0])] & ' ' & $aDate[1] & ', ' & $aDate[2] Return SetError(1, 0, 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...
Thatsgreat2345 Posted November 23, 2006 Share Posted November 23, 2006 $sDateIn = _DateToString("09/25/2006") MsgBox(64, 'Info', $sDateIn) Func _DateToString($sDate) Local $aMon[13] = ['','Jan','Feb','March','April','May','June','July','Aug','Sep','Oct','Nov','Dec'] Local $aDate = StringRegExp($sDate, '^(\d{1,2})/(\d{1,2})/(\d{2}|\d{4})$', 1) If IsArray($aDate) Then Return $aMon[Int($aDate[0])] & ' ' & $aDate[1] & ', ' & $aDate[2] Return SetError(1, 0, 0) EndFunchahah was going to do stringreg but was to lazy since he already wrote a script that worked xD 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