Sign in to follow this  
Followers 0
chun914

date calculation

6 posts in this topic

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

Share this post


Link to post
Share on other sites



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

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, :D If you hit a wall, come ask for more help :D. Hope it helps.....

Share this post


Link to post
Share on other sites

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, :D If you hit a wall, come ask for more help :D. Hope it helps.....

I would use DateAdd() because this aint gonna work always .... :D


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thanks so much

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0