retrieve file creation date

SOLVED

Hello,

I would like to know if it is possible to retrieve file creation date from script.
Example C:\SAFEX3\... or C:\Test\myfile.txt

the goal would be to delete files older than 3 months so that they are not imported by a reccuring task.

Is it possible ? do I need to use a batch file?

Thanks !

  • 0
    SUGGESTED

    The below code would give you the number of days since the file was last modified. This is using filpath so it's assuming that the file is in a volume defined in x3, in this case in the TMP folder.

    (date$ - [01/01/1970]) - (filinfo(filpath("TMP", ",myfile", "txt") , 9) / 86400)

    The below would round it

    fix( (date$ - [01/01/1970]) - (filinfo(filpath("TMP", ",myfile", "txt") , 9) / 86400) )

  • +1
    verified answer

    You can make use of the VOLUME class to get the information you need, remember that the area you are the file is located needs to be defined as a "Sage X3 storage area" and/or the is must be defined in the runtime sandbox configuration file. The below will return the date the file created as a datetime value. 

    local Integer XASTATUS
    local Datetime XDATETIME
    local Char XVOLUME
    local Char XFILENAME
    [L]XVOLUME = "TMP" # X3 Storage area name
    [L]XFILENAME = "myfile.txt" # File name + extension

    [L]XASTATUS = Func ASYRSTO.GETFILEDATETIME([L]XVOLUME, [L]XFILENAME, [L]XDATETIME)