Filter Files on Timestamp

Stef-BStef-B Member Posts: 26
edited 2009-11-10 in Navision Attain
I need to set a filter on the Time field of the virtual File Table.
The filter should show only the Files with a Time < now-5Minutes (e.g. older then 5 Minutes)

I tried so many ways to convert currentdaytime back and forth and nothing worked.

Most likely it's a simple task but right now im a little bit helpless.

Thank you in advance
Stef

Answers

  • kinekine Member Posts: 12,562
    What about moving "old" files after processing them into another folder and have rule, that in this folder are only files to be processed?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Stef-BStef-B Member Posts: 26
    The files I want to ignore are probably not completely finished, as the program that fills them takes some minutes to build them. If I start the reading process on a not finished file I get unpredictable conditions, and I just want to avoid this.

    My problem ist to determine what is a new file. Wether in the filter or later in the Repeat Until Loop. I have difficulties to compare the timestamp with a value of Time-5Minutes.
    Could you help me with this? I just never programmed something with Time up until now. I Know how to calculate with date and dateformula but not with time.
  • kinekine Member Posts: 12,562
    To test if file is finished you can try to open it for Write mode... if it fail, the file is open by someone else...
    The second process could create the files in different folder and move only finished files into the target folder for processing...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    My experience is that Kines suggestion is the best way to do it. If you move the files then its much reliable.
    David Singleton
  • Stef-BStef-B Member Posts: 26
    That just won't help!
    The Files are created line by line and are not locked in the time between (2-5 Seconds inbetween each line). I can not influence this behaviour. I just have to wait a certain amount of time after the creation time. that's all i want. After i processed the files in Nav i move them to a different folder but that wont help me in the beginning. so i ask again

    How do I calculate a Time minus 5 five minutes? What variable type do I need to compare this to the timestamp value of the File Rec.
  • reijermolenaarreijermolenaar Member Posts: 256
    Hi Stef,

    You can simply subtract milliseconds from a time.
    YourTime := TIME - (1000 * 60 * 5);
    

    Regards,
    Reijer Molenaar
    Object Manager
  • Stef-BStef-B Member Posts: 26
    :thumbsup:
    Thats it! Works perfect! so simple.. working with integer ... and I tried with variables with datetime and back and forth... ](*,)
Sign In or Register to comment.