huskies Posted March 17, 2009 Posted March 17, 2009 with _DateTimeSplit it can split 2005/01/01 14:30 into date and time is there one that can split the date? <It Shall Be Done>
BugFix Posted March 17, 2009 Posted March 17, 2009 (edited) with _DateTimeSplit it can split 2005/01/01 14:30 into date and time is there one that can split the date? Use string functions: $date = '2005/01/01 14:30' $year = StringLeft($date, 4) $mon = StringMid($date, 6, 2) $day = StringMid($date, 9, 2) MsgBox(0, 'Date', 'Year: ' & $year & @LF & 'Month: ' & $mon & @LF & 'Day: ' & $day) ; or with split $aDate = StringSplit(StringTrimRight($date, 6), '/') MsgBox(0, 'Date with StringSplit', 'Year: ' & $aDate[1] & @LF & 'Month: ' & $aDate[2] & @LF & 'Day: ' & $aDate[3]) Edited March 17, 2009 by BugFix Best Regards BugFix
erik7426 Posted March 17, 2009 Posted March 17, 2009 Why not use _DateTimeSplit and just ignore the time values #include <Date.au3> #include <Array.au3> Dim $MyDate Dim $MyTime _DateTimeSplit("2009/03/17", $MyDate, $MyTime) _ArrayDisplay($MyDate,"Date Info")
huskies Posted March 17, 2009 Author Posted March 17, 2009 (edited) Why not use _DateTimeSplit and just ignore the time values #include <Date.au3> #include <Array.au3> Dim $MyDate Dim $MyTime _DateTimeSplit("2009/03/17", $MyDate, $MyTime) _ArrayDisplay($MyDate,"Date Info") I meant how to turn 2009/03/17 into 2009 ,March and 17. I don't have a time variable, that was just an example. @BugFix, thank you , it was a very good idea! Edited March 17, 2009 by huskies <It Shall Be Done>
erik7426 Posted March 17, 2009 Posted March 17, 2009 I meant how to turn 2009/03/17 into 2009 ,March and 17. I don't have a time variable, that was just an example. @BugFix, thank you , it was a very good idea! This would give you the name of the month if that is what you are looking for... #include <Date.au3> Dim $MyDate Dim $MyTime _DateTimeSplit("2009/03/17", $MyDate, $MyTime) $Year = $MyDate[1] $Month = _DateToMonth($MyDate[2],0) $Day = $MyDate[3] MsgBox(0,"","Year: " & $Year & @CRLF & "Month: " & $Month & @CRLF & "Day: " & $Day)
Szhlopp Posted March 17, 2009 Posted March 17, 2009 I meant how to turn 2009/03/17 into 2009 ,March and 17. I don't have a time variable, that was just an example. @BugFix, thank you , it was a very good idea! I had to create this for someone a few months back. Modify it to your hearts content. #Include <Date.au3> MsgBox(0, "", _DateSubtract(-1)) Func _DateSubtract($iSubtract) Local $Days[7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] Local $Month[12] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] $Split = StringSplit(_DateAdd('d', $iSubtract, _NowCalcDate()), "/") $CurentDate = $Days[_DateToDayOfWeekISO($Split[1], $Split[2], $Split[3])] & ", " & $Month[$Split[2] - 1] & " " & $Split[3] & ", " & $Split[1] Return $CurentDate EndFunc RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+'
huskies Posted March 17, 2009 Author Posted March 17, 2009 This would give you the name of the month if that is what you are looking for... #include <Date.au3> Dim $MyDate Dim $MyTime _DateTimeSplit("2009/03/17", $MyDate, $MyTime) $Year = $MyDate[1] $Month = _DateToMonth($MyDate[2],0) $Day = $MyDate[3] MsgBox(0,"","Year: " & $Year & @CRLF & "Month: " & $Month & @CRLF & "Day: " & $Day) thank you, so in here is $myDate separating the 2009/03/17 into 3 arrays based on the slash "/" or does this only work on dates? say if i had "random/whatever/don'tknow" would it work? $Year = $MyDate[1] $Month = $MyDate[2] $Day = $MyDate[3] <It Shall Be Done>
erik7426 Posted March 17, 2009 Posted March 17, 2009 thank you, so in here is $myDate separating the 2009/03/17 into 3 arrays based on the slash "/" or does this only work on dates? say if i had "random/whatever/don'tknow" would it work? $Year = $MyDate[1] $Month = $MyDate[2] $Day = $MyDate[3] If you try "random/whatever/don'tknow" each of the elements in $MyDate contains -1. So, you must have something that resembles a date in the format of yyyy/mm/dd in order for the function to work.
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