Jump to content

add three days on to current date...?


Recommended Posts

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.

Link to comment
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])

Link to comment
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?

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

Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...