caustin Posted August 28, 2008 Share Posted August 28, 2008 I'm trying to output the date in the format "Thu Aug 29". There are many date functions but no single function seems to be able to do this(unless I overlooked it). I want to store this formatted date into a variable and then subtract 1 day and store into another variable so I need to be careful that the code "knows" that if today is Mon Sep 1, that yesterday was Sun Aug 31. Thanks - CA Link to comment Share on other sites More sharing options...
Szhlopp Posted August 28, 2008 Share Posted August 28, 2008 I'm trying to output the date in the format "Thu Aug 29". There are many date functions but no single function seems to be able to do this(unless I overlooked it). I want to store this formatted date into a variable and then subtract 1 day and store into another variable so I need to be careful that the code "knows" that if today is Mon Sep 1, that yesterday was Sun Aug 31. Thanks - CA Dim $Days[7] = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] Dim $Month[12] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] $CurentDate = $Days[@WDAY - 1] & " " & $Month[@MON - 1] & " " & @MDAY MsgBox(0, "", $CurentDate) 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 '+' Link to comment Share on other sites More sharing options...
Szhlopp Posted August 28, 2008 Share Posted August 28, 2008 (edited) Doh noticed you wanted to subtract a day. Here it is: #Include <Date.au3> Dim $Days[7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] Dim $Month[12] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] $Split = StringSplit(_DateAdd('d', -1, _NowCalcDate()), "/") $CurentDate = $Days[_DateToDayOfWeekISO($Split[1], $Split[2], $Split[3])] & " " & $Month[$Split[2] - 1] & " " & $Split[3] MsgBox(0, "", $CurentDate ) Edited August 28, 2008 by Szhlopp 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 '+' Link to comment Share on other sites More sharing options...
caustin Posted August 28, 2008 Author Share Posted August 28, 2008 Thanks - this looks like it will work. I was hoping there was a UDF that would output in any format but guess not. Thanks again. CA Link to comment Share on other sites More sharing options...
Szhlopp Posted August 29, 2008 Share Posted August 29, 2008 Thanks - this looks like it will work. I was hoping there was a UDF that would output in any format but guess not. Thanks again. CA Np, Also, you can easily change how it outputs... $CurentDate = $Days[_DateToDayOfWeekISO($Split[1], $Split[2], $Split[3])] - The day & " " & $Month[$Split[2] - 1] - The month & " " & $Split[3] - The date (28th) =) 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 '+' Link to comment Share on other sites More sharing options...
caustin Posted August 29, 2008 Author Share Posted August 29, 2008 Perhaps my original question was not clear.I need to store today's date into a variable in the format "Wed Aug 29"I need to subtract 1 day from today's date to get yesterday's dateI need to store yesterday's date into a variable in the same format "Wed Aug 28"Subtracting 1 from @WDAY won't work because if it happens to be be Sunday(0) subtracting 1 will go negativeHere's what I had so far in the original post$tTime = _Date_Time_GetSystemTime() $aTime = _Date_Time_SystemTimeToArray($tTime) $sShortDayName = _DateDayOfWeek( $aTime[7], 1 );element 7 contains the day of the week as an integer $sShortMonthName = _DateToMonth($aTime[0], 1) ;element 0 contains the month of the year as a number $Today = $sShortDayName & " " & $sShortMonthName & " " & @MDAY ; "Fri Aug 29";Can I do something along the following lines to create yesterday?$sNewDate = _DateAdd('D',-1, $tTime) ; subtract 1 day from today's date;What would go here??Thanks - CA 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