Hello All,
I need some help on subtracting n days or hours from date obtained by GETDATE function: how can I obtain a date of today subtracting 7 days or 8 hours using $Today =GETDATE(FORMAT0). I need it in order to get only files produced in the last 8 hours, can somebody help me?
thanks a lot
Alessandro
I need some help on subtracting n days or hours from date obtained by GETDATE function: how can I obtain a date of today subtracting 7 days or 8 hours using $Today =GETDATE(FORMAT0). I need it in order to get only files produced in the last 8 hours, can somebody help me?
thanks a lot
Alessandro
Hello Alessandro,
It can be done this way:
Then, to download the files with a modification time greater than $newdate you can do the following:
It can be done this way:
Code: Select all
# Example. Subtracting 7 days and 8 hours from
# the current date/time
$today=GETDATE(FORMAT0)
PRINT("Currente time is: ".$today)
# 7 days and 8 hours are converted to seconds
# and subtracted from the current date/time
$newdate=$today-(7*24*60*60)-(8*60*60)
PRINT("New time is: ".$newdate)
Then, to download the files with a modification time greater than $newdate you can do the following:
Code: Select all
# Get the file listing of the FTP server
GETLIST($filelist,REMOTE_FILES,"*.*")
# For each file, get the modification time and download
# if that time is greater than the calculated time
FOREACH $file IN $filelist
$file_modification_time=GETFILETIME(REMOTE,$file)
IF($file_modification_time>$newdate)
GETFILE($file)
END IF
END FOREACH
liked Script FTP? Try our other product Email Parser
Huge!!!
Fantastic !!! issue solved
thanks a lot
kindest regards
Fantastic !!! issue solved
thanks a lot
kindest regards