2 Replies Latest reply: Jul 22, 2016 12:02 PM by Light Section RSS

    Filelist loop not working

    Light Section

      Hi All,

       

      The below chunk of code does not give me the desired output. I am trying to skim through all filenames in a folder and extract the maximum date. Please let me know what might be wrong here:

       

      // -----------------------------------------------------------

      Let vMaxMonthYear = MakeDate(1900);

      For Each vFile in FileList('$(viTimeSQLExtracts)' & 'IPower_Monthly*.qvd')

       

        Let vCurMonthYear =  MonthEnd(MakeDate(subfield('$(vFile)', '_', 3), subfield('$(vFile)', '_', 4)));

        If $(vCurMonthYear) > $(vMaxMonthYear) then

          LET vMaxMonthYear = $(vCurMonthYear);

        End If

       

      Next vFile

       

      // For testing purpose only

      Let vTest_CurMonthYear =  MonthEnd(MakeDate(subfield('$(vFile)', '_', 3), subfield('$(vFile)', '_', 4)));

      Trace $(vTest_CurMonthYear);

      Trace 'Latest Month: $(vMaxMonthYear)';