Sign in to follow this  
Followers 0
possy_99

add three days on to current date...?

11 posts in this topic

I've been tring to make a script which runs some commands then sets the system date forward three days.

the problem being obviously month changes, as not all months have the same number of days, and even leap years could be a problem.

Can I somehow use YDATE macro to make this any easier? something like $newdate = @YDATE + 3, but then because I'm setting the data via comspec which is expecting DD-MM-YY format, I get stuck, lol.

is there any simple way of doing this?

thanks for any help.

Share this post


Link to post
Share on other sites



What about _DateAdd ?

Taken from Help..

#include <Date.au3>

; Add 5 days to today
$sNewDate = _DateAdd( 'd',5, _NowCalcDate())
MsgBox( 4096, "", "Today + 5 days:" & $sNewDate )

Share this post


Link to post
Share on other sites

thanks for the pointer m8, I'm always in the help file too it is a great resource. Musn't have seen this one though, lol.

Share this post


Link to post
Share on other sites

any pointers on how I'd get $sNewDate in to DD-MM-YY, so I can then pass on to a command prompt.. in this manner..

RunWait(@ComSpec & " /c " & 'Date ' & $newdate[DD-MM-YY], "")

appreciated :)

Share this post


Link to post
Share on other sites

Try this..

_DateTimeSplit($sNewDate,$MyDate,$MyTime)

$YY=StringTrimLeft($MyDate[1],2)
$MM=StringFormat("%02i",$MyDate[2])
$DD=StringFormat("%02i",$MyDate[3])
$sDate=$YY & "-" & $MM & "-" & $DD

I'm not sure StringFormat can trim the variables from left so thus StringTrimLeft is used for $YY :) I was only able to trim the string from right using StringFormat like that..

$YY=StringFormat("%.2s",$MyDate[1])

Share this post


Link to post
Share on other sites

#include <Date.au3>

; Add 5 days to today
$sNewDate = _DateAdd( 'd',5, _NowCalc())
$sNewDate =  _DateTimeFormat($sNewDate, 2)
MsgBox( 4096, "", $sNewDate)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I'm not sure this is what he wants. Using _DateTimeFormat returns year in YYYY format. And as far as I understand, he probably wants year in YY format?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I'm not sure this is what he wants. Using _DateTimeFormat returns year in YYYY format. And as far as I understand, he probably wants year in YY format?

nor I ....

it is a consistant date use

just another users option

8)

BTW... just a tip

i have NUMEROUS files with dates. Because of the many many files over years, i use yyyy/mm/dd format to help aid in my file searches

example

2004-05-21

2005-06-14

2006-03-12

this is how they appear on my "sort"

however, by dd/mm/yyyy

the sort is not correct

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Could, I have not been too successful, this be made to display the next day in long form (Wednesady, Thursday etc).

I.E. such as an information line in a messagebox "...don't forget to call <<the tomorrow display>> agent.

Edited by Beelzel

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hi,

#include <Date.au3>

; Add 3 days to today

$sNewDate = _DateAdd( 'd',3, _NowCalc())

$sShortDate = _DateTimeFormat($sNewDate, 2)

MsgBox( 4096, "", $sShortDate)

$sLongDate = _DateTimeFormat($sNewDate, 1)

MsgBox( 4096, "", $sLongDate)

$sShortDate = StringReplace($sShortDate, "/","-")

$sShortDate = StringReplace($sShortDate, "-20","-")

MsgBox( 4096, "", $sShortDate)

This will work for short date in local regional date format, which will be what he is requesting for DOS; though it won't appear to have worked if your local format is different [eg USA] [although yopu'll need above type formatting if this isn't accurate; DOS befor W2k, or strange DOS settings?]

Best, Randall

Edited by randallc

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