If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
FileDateTime Question
I have gotten my code this far but not working.
Dim MyStamp as Date MyStamp = FileDateTime(C:\Filecopy.txt) If MyStamp = Date Then 'If Filecopy.txt modified date equals the current date. MsgBox "File ok" Goto End1 End If MsgBox "File not ok" End1: |
#2
|
|||
|
|||
FileDateTime Question
Jay
"... not working..." is pretty loose... Do you mean that it returns a value, but the wrong one? Do you mean that it sometimes returns a wrong value, and sometimes the right one? Do you mean that it fails and generates an error message? (what does the message say?) Do you mean that your PC bursts into flames when you try this? More specific descriptions will lead to more specific suggestions... Regards Jeff Boyce Microsoft Office/Access MVP "Jay" wrote in message ... I have gotten my code this far but not working. Dim MyStamp as Date MyStamp = FileDateTime(C:\Filecopy.txt) If MyStamp = Date Then 'If Filecopy.txt modified date equals the current date. MsgBox "File ok" Goto End1 End If MsgBox "File not ok" End1: |
#3
|
|||
|
|||
FileDateTime Question
Jeff Boyce wrote:
Jay "... not working..." is pretty loose... Do you mean that it returns a value, but the wrong one? Do you mean that it sometimes returns a wrong value, and sometimes the right one? Do you mean that it fails and generates an error message? (what does the message say?) Do you mean that your PC bursts into flames when you try this? More specific descriptions will lead to more specific suggestions... Regards Jeff Boyce Microsoft Office/Access MVP "Jay" wrote in message ... I have gotten my code this far but not working. Dim MyStamp as Date MyStamp = FileDateTime(C:\Filecopy.txt) If MyStamp = Date Then 'If Filecopy.txt modified date equals the current date. MsgBox "File ok" Goto End1 End If MsgBox "File not ok" End1: Sorry about that. I just got off google and my head is spinning in circles. I have a need to compair a text file's modification date with the current date. If it matches then it is good. If the modification date is older then it is rejected. I made a filecopy.txt file with the modified date matching the current date. However, I get the msgbox "File not ok". I am not getting a match between the current date and the modified date of the file. |
#4
|
|||
|
|||
FileDateTime Question
Jay
Were this my task, I'd probably start out displaying what the FileDateTime actually is, before trying to compare. By the way, if the name implies accurately, the value is a date/time value, so comparing to only a date won't get it. You might want to take a look at the functions that extract the date-only portion... Regards Jeff Boyce Microsoft Office/Access MVP "Jay" wrote in message ... Jeff Boyce wrote: Jay "... not working..." is pretty loose... Do you mean that it returns a value, but the wrong one? Do you mean that it sometimes returns a wrong value, and sometimes the right one? Do you mean that it fails and generates an error message? (what does the message say?) Do you mean that your PC bursts into flames when you try this? More specific descriptions will lead to more specific suggestions... Regards Jeff Boyce Microsoft Office/Access MVP "Jay" wrote in message ... I have gotten my code this far but not working. Dim MyStamp as Date MyStamp = FileDateTime(C:\Filecopy.txt) If MyStamp = Date Then 'If Filecopy.txt modified date equals the current date. MsgBox "File ok" Goto End1 End If MsgBox "File not ok" End1: Sorry about that. I just got off google and my head is spinning in circles. I have a need to compair a text file's modification date with the current date. If it matches then it is good. If the modification date is older then it is rejected. I made a filecopy.txt file with the modified date matching the current date. However, I get the msgbox "File not ok". I am not getting a match between the current date and the modified date of the file. |
#5
|
|||
|
|||
FileDateTime Question
I'm surprised you're not getting an error. The argument to FileDateTime
needs to be a string: MyStamp = FileDateTime("C:\Filecopy.txt") Note though, that FileDateTime is going to return a date/time combination, whereas Date only returns the date. The odds of you finding them with the same value are extremely small (the file would have had to have been updated at midnight this morning). To strip the time off MyStamp, use the DateValue function: If DateValue(MyStamp) = Date Then -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Jay" wrote in message ... I have gotten my code this far but not working. Dim MyStamp as Date MyStamp = FileDateTime(C:\Filecopy.txt) If MyStamp = Date Then 'If Filecopy.txt modified date equals the current date. MsgBox "File ok" Goto End1 End If MsgBox "File not ok" End1: |
#6
|
|||
|
|||
FileDateTime Question
Douglas J. Steele wrote:
I'm surprised you're not getting an error. The argument to FileDateTime needs to be a string: MyStamp = FileDateTime("C:\Filecopy.txt") Note though, that FileDateTime is going to return a date/time combination, whereas Date only returns the date. The odds of you finding them with the same value are extremely small (the file would have had to have been updated at midnight this morning). To strip the time off MyStamp, use the DateValue function: If DateValue(MyStamp) = Date Then That worked. I had everything but the DateValue which gave me the date only. |
Thread Tools | |
Display Modes | |
|
|