How to retrieve the files between two dates through Vb?

Posted on 2003-03-11
Medium Priority
Last Modified: 2012-05-04
How to retrieve the files between two dates through Vb?
This is my code. Its working but the last file was not displaying which was created 03/11/2003.

fileName = "E:\Archive\2\700\708\"
Set mainfile = fso.GetFolder(fileName)
Set filesCollection = mainfile.Files
For Each temp1 In filesCollection
    'MsgBox temp1.name
    fileCreationDate = temp1.DateLastModified
    If (fileCreationDate <= #3/25/2002#) and (fileCreationDate >= #3/11/2003#)) then
    MsgBox temp1.name
    'MsgBox temp1.DateLastModified
    End If

Advance thanks.

Question by:merlin_vb1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

JH0401 earned 140 total points
ID: 8112449
Try this:

If Format(fileCreationDate,"#") >= Format (#3/25/2002#,"#") and Format(fileCreationDate,"#") <= Format (#3/11/2003#,"#") Then
msgbox temp1.name
end if

Author Comment

ID: 8158195
Thanks for your help.
Its working fine.

How can i close this Question? plese help me.


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question