You can index the datalog entry from the earliest entry, or latest entry. Positive values are relative to the first entry, and negative values are relative to the last entry. A record # of -1 will return the last entry, -2 is the second to last entry, etc.
To find the number of entries, you will need to create a while loop, while the "i" index to the record # input and to the edge of the loop and the "invalid record #" to the termination condition (stop if true). The output of the while loop will be the # of records in the datalog file.