Jump to content

@year @Mon @Mday


Recommended Posts

Hello I have a little big problem.

I made a program that recovers data by ftp from today and back for 2 days;

in practice retrieves the file with date of today, yesterday and the day before yesterday.

So to do this' I used a simple procedure to subtract the days of the date hereof:

$ year = @ YEAR

$ month = @ MON

$ day = @ MDAY

$ date = $ year & $ month & $ day

data_1 $ = $ year & $ month & ($ day - 1)

data_2 $ = $ year & $ month & ($ day - 2)

The procedure has worked for 10-15 days. At any moment when I launch the program (the executable program mean that I have created 15 days ago) the program gives me the variable and the variable $ $ data_1 data_2 are equal to zero, if I debug it tells me that have results for "false".

Because they are ignorant and I was very happy to have done little program and it worked, I explain now you know why 'should not be more'.

Premise that the executable file 'was compiled in both 32-bit and 64 bit (xp and 7) and is used on 4 different pc, and all by the fact that I do not get more' files for the two variables question.

I do not remember if it worked the last time we were still in July. (you know who does not have any control over how many days a month, but since I use it only when I know I can use it :))

Aiutooooo!!

Thanks

Pastebin : http://pastebin.com/YvTRn1xC

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Link to comment
Share on other sites

Your script wont' work at the start of a month and return an invalid date. Let's say 2012-08-01 would result in 2012-08-00 or even 2012-08--1

Use function _DateAdd to add or subtract dates.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

OK , i have execute script in the day 04/08 , 05/08 , 06/08 , 07/08 ECC. AND NO WORK.

PLEASE , I AM NO SPECK ENGLISH , I AM USE GOOGLE.

THANK YOU

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Link to comment
Share on other sites

The following example takes the current data and subtracts 1 resp. 2 and assigns it to variables:

#include <date.au3>
$date1 = _DateAdd("d", -1, _NowCalcDate())
$date2 = _DateAdd("d", -2, _NowCalcDate())
ConsoleWrite($date1 & @LF)
ConsoleWrite($date2 & @LF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Properly written (you have spaces where none should be and $s that are out of place) the code you gave works fine. I just added the StringFormat() to set @MDAY to 2 digits.

$year = @YEAR
$month = @MON
$day = @MDAY
$date = $year & $month & $day
$data_1 = $year & $month & StringFormat("%02d",$day - 1)
$data_2 = $year & $month & StringFormat("%02d",$day - 2)
ConsoleWrite("Date: " & $date & @CRLF & "Data_1: " & $data_1 & @CRLF & "Data_2: " & $data_2 & @CRLF)

This however is shorter and does the same thing.

$date = @YEAR & @MON & StringFormat("%02d",@MDAY)
$data_1 = @YEAR & @MON & StringFormat("%02d",@MDAY - 1)
$data_2 = @YEAR & @MON & StringFormat("%02d",@MDAY - 2)
ConsoleWrite("Date: " & $date & @CRLF & "Data_1: " & $data_1 & @CRLF & "Data_2: " & $data_2 & @CRLF)

All that being said; Water is correct in what function to use.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...