Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

MENU MENU
Post a message here if you find anything wrong in ScriptFTP.
According to tutorial, I print time as below:

FTP Script
  1. PRINT (GETDATE(FORMAT0))
  2. PRINT (GETDATE(FORMAT0)-(4*24*60*60))

The result is something like below, please note the format is changed, the month and date are missing "0", two digits format changed to 1 digit. This makes me to retrieve month and date difficult.
2017_06_13-16_41_59
2017_6_9-16_41_59
You try to subtract a number from the formatted string - you do not have to wait for the correct result...
And the topic was raised two times only recently...
http://www.scriptftp.com/forum/general-f6/way-to-check-number-of-days-in-a-month--t9027.html#p14942
I code "yesterday" as blow, and test OK on any state I guess (20170101, 20170131, 20171203, 20171212).
FTP Script
  1. $currDate=GETTIME()
  2.  
  3. $oneDate=$currDate-(1*24*60*60)
  4. $oneYear=TEXTCUT($oneDate, 1, 4)
  5. $oneMonth=TEXTCUT($oneDate, 6, 2)
  6. $flagMonth=TEXTCUT($oneMonth, 2, 1)
  7. IF($flagMonth=="_")
  8.     $oneMonth="0" . TEXTCUT($oneMonth, 1, 1)
  9.     $oneDay=TEXTCUT($oneDate, 8, 2)
  10.     $flagDay=TEXTCUT($oneDay, 2, 1)
  11.     IF($flagDay=="-")
  12.         $oneDay="0" . TEXTCUT($oneDay, 1, 1)
  13.     END IF
  14.     $oneDay=TEXTCUT($oneDate, 9, 2)
  15.     $flagDay=TEXTCUT($oneDay, 2, 1)
  16.     IF($flagDay=="-")
  17.         $oneDay="0" . TEXTCUT($oneDay, 1, 1)
  18.     END IF
  19. $strOneDate=$oneYear . $oneMonth . $oneDay
  20.  
  21. PRINT($strOneDate)
Hi there,

Yes, there is a bug when substracting seconds from a date. As reported by field_flying, the output is not correct and it should match YYYY_MM_DD-HH_MM_SS, there are some missing zeroes.

I have fixed it and uploaded the new setup here:

https://www.ScriptFTP.com/beta