chun914 Posted May 8, 2007 Share Posted May 8, 2007 I'd like to calculate the date.. the format i have is . YYMMDD is that any easy way just to subtract it by 1 day..... e.g. 070501 - 1 ,, result = 070430 is there any method to convert YYMMDD to a format that can be calculated... i don't want to have too many ''select,case' if then'' with YYMMDD Link to comment Share on other sites More sharing options...
BrettF Posted May 8, 2007 Share Posted May 8, 2007 I'd like to calculate the date.. the format i have is . YYMMDD is that any easy way just to subtract it by 1 day..... e.g. 070501 - 1 ,, result = 070430 is there any method to convert YYMMDD to a format that can be calculated... i don't want to have too many ''select,case' if then'' with YYMMDDSo if the date was like this: 2007/05/08, then try this $date = "2007/05/08" $datestrip = StringSplit ($date, "/") $newdate = $datestrip[1] & "/" & $datestrip[2] & "/" & $datestrip[3]-1 MsgBox (0, "Date Calc", "Old Date: "&$date &@CRLF&"New Date: "&$newdate) You can refine it. Give it ago, add a if statement, If you hit a wall, come ask for more help . Hope it helps..... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Developers Jos Posted May 8, 2007 Developers Share Posted May 8, 2007 So if the date was like this: 2007/05/08, then try this $date = "2007/05/08" $datestrip = StringSplit ($date, "/") $newdate = $datestrip[1] & "/" & $datestrip[2] & "/" & $datestrip[3]-1 MsgBox (0, "Date Calc", "Old Date: "&$date &@CRLF&"New Date: "&$newdate) You can refine it. Give it ago, add a if statement, If you hit a wall, come ask for more help . Hope it helps..... I would use DateAdd() because this aint gonna work always .... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
searchresult Posted May 8, 2007 Share Posted May 8, 2007 I would use DateAdd() because this aint gonna work always .... #Include <date.au3> Dim $date $date = _NowDate() MsgBox(0,"",$date) $datestrip = StringSplit ($date, ".") $newdate = $datestrip[1] & "/" & $datestrip[2] & "/" & $datestrip[3] MsgBox (0, "Date Calc", "Old Date: "&$date &@CRLF&"New Date: "&$newdate) ;in a line code up $newdate = $datestrip[1] & "/" & $datestrip[2] & "/" & $datestrip[3] ;$datestrip[1] if you add a number to this you will add day ;$datestrip[2] if you add a number to this you will add month ;$datestrip[3] if you add a number to this you will add year ;all of this goes for any math operation Link to comment Share on other sites More sharing options...
Developers Jos Posted May 8, 2007 Developers Share Posted May 8, 2007 I was more thinking of this method: #Include<date.au3> $InputDate = "070508" $CalcDate = "20" & StringMid($inputdate,1,2) & "/" & StringMid($inputdate,3,2) & "/" & StringMid($inputdate,5,2) $NewDate = _DateAdd("d",-1,$CalcDate) ConsoleWrite("Inputdate - 1 is " & $NewDate & @LF) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
chun914 Posted May 11, 2007 Author Share Posted May 11, 2007 thanks so much 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