Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8241101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:43:16+00:00 2026-06-07T20:43:16+00:00

I am creating a SQL Server integration package that requires some VBScript. Basically, every

  • 0

I am creating a SQL Server integration package that requires some VBScript. Basically, every few days there is a file that is uploaded to a folder on my computer. This file always has a different name, but it always contains the same string.

For example, the file for yesterday could have been “John J July 15.xlsx” and the file for tomorrow might be “John Jones Jul 17 2012.xlsx”. They all contain “John” and they always will. I always want to set my variable to equal the filename of the file that contains “John” AND has a DateCreated attribute equal to today.

Is there something wrong with my code? I can’t get it to work. Is the “Today.Date” also returning a time? I only want it to return a date. Does the Name attribute return the extension also?

    Public Sub Main()
    Dim f, fl, fs As Object
    Dim filedate As Date = Microsoft.VisualBasic.Today.Date
    Dim firstFileName As String

    fs = CreateObject("Scripting.FileSystemObject")
    fl = fs.GetFolder("E:\myFolder")

    For Each f In fl.Files
        If f.DateCreated = filedate And f.Name = "John*" Then
            firstFileName = f.Name
            Dts.Variables("ExcelSource").Value = "E:\myFolder\" & firstFileName
        End If
    Next
    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:43:18+00:00Added an answer on June 7, 2026 at 8:43 pm

    I don’t believe the wildcard character in your IF statement above will work as you intend here. It will compare the filename with the literal “*” character, and match nothing. I might suggest something like:

    *EDIT: The DateCreated property does resolve to the second, so the comparison you have above won’t work, either. Here’s a very rough and untested illustration of one way you could modify to test for the proper date (omitting the seconds resolution).*

    ...
    If Year(fileDate)=Year(f.DateCreated) and _
       Month(fileDate)=Month(f.DateCreated) and _ 
       Day(fileDate)= Year(f.DateCreated) and  _
       Left(f.Name,4)="John" Then
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Preamble: I'm creating some tables in SQL Server that will be accessed via Linq-to-entities
MSDN states that there are 4 steps in creating a server alias: In SQL
I'm creating a trigger in SQL Server after INSERT, UPDATE and DELETE. Is there
I'm creating a DotNetNuke module that needs to read entries from a SQL Server
I'm creating an SQL file, placing this file into a zip file with some
I'm creating an install package using InnoSetup and installing SQL Server 2005 Express. Here's
I am creating a script that will be run in a MS SQL server.
I am creating a C++/CLI application that connects to a SQl Server 2008 database.
I am creating a company directory and need some help with the SQL Server
I am creating a generic XML to SQL Server data driver (In c#), that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.