Querying on date fields originally populated with value from FileDateTime (1 Viewer)

PatThePostie

New member
Local time
Today, 20:02
Joined
Jul 14, 2017
Messages
4
I have a table in Access that contains a list of file names and their modified dates, which is used to check if a certain file in a filing system has changed. The file modified date field is populated using the output of FileDateTime. However, whenever I query this table using the file name and the file modification time, where the file modification time is determined using the FileDateTime function again, it always fails. I've had to resort to do a look-up on the file name only, then using VBA code to check if the returned file modification date field is the same as the value returned from the file system for the same file using the FileDateTime function and this works no problem.


In writing the data to the table using VBA code, specifically an ADODB recordset. When creating the SQL query, I'm parsing the output of the FileDateTime function, that was performed on the file, through code to convert it to an SQL date, thus:
Code:
Function SQLDateTime(DateTimeToConvert As Variant) As String
      SQLDateTime = "#" & Format(CDate(DateTimeToConvert), "mm/dd/yyyy hh:nn:ss") & "#"
  End Function
Any idea where I'm going wrong? :banghead:
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:02
Joined
Oct 29, 2018
Messages
21,509
What does "always fails" mean? Would it have anything to do with files modified in the afternoons? If so, maybe your format should be more something like:
Code:
"mm/dd/yyyy hh:nn:ss ampm"
Just curious...
 

Users who are viewing this thread

Top Bottom