Hi All,
I'm trying to find if a file name that includes the date is before todays to
do some procedures.
In my IF statement is working is just a few dates before but not is a year
before.
How can I fix this?
Tks in advance...
This is what I have:
'Set today's date
Dim todayDay As String
If Month(Now) < 10 Then todayDay = todayDay & "0" & Month(Now) Else todayDay
= todayDay & Month(Now)
If Date.Today.Day < 10 Then todayDay = todayDay & "0" & Date.Today.Day Else
todayDay = todayDay & Date.Today.Day
todayDay = todayDay & CStr(Year(Now). ToString)
'Get Files from Spool Folder
objFolder = dir.GetDirector yRoot(folderNam e)
colFiles = dir.GetFiles(fo lderName)
If colFiles(i).Sub string(colFiles (i).LastIndexOf ("\") + 1, 8) <= todayDay
Then 8 1379
"JFB" <he**@jfb.com > wrote in message
news:uV******** ******@TK2MSFTN GP12.phx.gbl... Hi All, I'm trying to find if a file name that includes the date is before todays to do some procedures. In my IF statement is working is just a few dates before but not is a year before. How can I fix this? Tks in advance... This is what I have: 'Set today's date
Dim todayDay As String
If Month(Now) < 10 Then todayDay = todayDay & "0" & Month(Now) Else todayDay = todayDay & Month(Now)
If Date.Today.Day < 10 Then todayDay = todayDay & "0" & Date.Today.Day Else todayDay = todayDay & Date.Today.Day
todayDay = todayDay & CStr(Year(Now). ToString)
'Get Files from Spool Folder
objFolder = dir.GetDirector yRoot(folderNam e)
colFiles = dir.GetFiles(fo lderName)
If colFiles(i).Sub string(colFiles (i).LastIndexOf ("\") + 1, 8) <= todayDay Then
Dim today As String = Now().ToString( "yyyymmdd")
Dim fileDate As String = ParseFileDateAn dStoreAsYYYYMMD D
If today >= fileDate
...
End If
HTH,
Mythran
what is the format of your filename date?
ie. is it file01032003.da t or something?
You can parse it into a date structure and then use simple comparison
operators.
"JFB" <he**@jfb.com > wrote in message
news:uV******** ******@TK2MSFTN GP12.phx.gbl... Hi All, I'm trying to find if a file name that includes the date is before todays to do some procedures. In my IF statement is working is just a few dates before but not is a year before. How can I fix this? Tks in advance... This is what I have: 'Set today's date
Dim todayDay As String
If Month(Now) < 10 Then todayDay = todayDay & "0" & Month(Now) Else todayDay = todayDay & Month(Now)
If Date.Today.Day < 10 Then todayDay = todayDay & "0" & Date.Today.Day Else todayDay = todayDay & Date.Today.Day
todayDay = todayDay & CStr(Year(Now). ToString)
'Get Files from Spool Folder
objFolder = dir.GetDirector yRoot(folderNam e)
colFiles = dir.GetFiles(fo lderName)
If colFiles(i).Sub string(colFiles (i).LastIndexOf ("\") + 1, 8) <= todayDay Then
Tks for you reply
But I already have the file name as MMDDYYYY
How can I parse the file name?
JFB
"Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message
news:u6******** ********@TK2MSF TNGP10.phx.gbl. .. "JFB" <he**@jfb.com > wrote in message news:uV******** ******@TK2MSFTN GP12.phx.gbl... Hi All, I'm trying to find if a file name that includes the date is before todays to do some procedures. In my IF statement is working is just a few dates before but not is a year before. How can I fix this? Tks in advance... This is what I have: 'Set today's date
Dim todayDay As String
If Month(Now) < 10 Then todayDay = todayDay & "0" & Month(Now) Else todayDay = todayDay & Month(Now)
If Date.Today.Day < 10 Then todayDay = todayDay & "0" & Date.Today.Day Else todayDay = todayDay & Date.Today.Day
todayDay = todayDay & CStr(Year(Now). ToString)
'Get Files from Spool Folder
objFolder = dir.GetDirector yRoot(folderNam e)
colFiles = dir.GetFiles(fo lderName)
If colFiles(i).Sub string(colFiles (i).LastIndexOf ("\") + 1, 8) <= todayDay Then
Dim today As String = Now().ToString( "yyyymmdd") Dim fileDate As String = ParseFileDateAn dStoreAsYYYYMMD D
If today >= fileDate ... End If
HTH, Mythran
theDate = Date.Parse ( theString )
"JFB" <he**@jfb.com > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Tks for you reply But I already have the file name as MMDDYYYY How can I parse the file name? JFB
"Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message news:u6******** ********@TK2MSF TNGP10.phx.gbl. .. "JFB" <he**@jfb.com > wrote in message news:uV******** ******@TK2MSFTN GP12.phx.gbl... Hi All, I'm trying to find if a file name that includes the date is before todays to do some procedures. In my IF statement is working is just a few dates before but not is a year before. How can I fix this? Tks in advance... This is what I have: 'Set today's date
Dim todayDay As String
If Month(Now) < 10 Then todayDay = todayDay & "0" & Month(Now) Else todayDay = todayDay & Month(Now)
If Date.Today.Day < 10 Then todayDay = todayDay & "0" & Date.Today.Day Else todayDay = todayDay & Date.Today.Day
todayDay = todayDay & CStr(Year(Now). ToString)
'Get Files from Spool Folder
objFolder = dir.GetDirector yRoot(folderNam e)
colFiles = dir.GetFiles(fo lderName)
If colFiles(i).Sub string(colFiles (i).LastIndexOf ("\") + 1, 8) <= todayDay Then
Dim today As String = Now().ToString( "yyyymmdd") Dim fileDate As String = ParseFileDateAn dStoreAsYYYYMMD D
If today >= fileDate ... End If
HTH, Mythran
"Robin Tucker" <id************ *************@r eallyidont.com> wrote in
message news:d9******** ***********@new s.demon.co.uk.. . what is the format of your filename date?
ie. is it file01032003.da t or something?
You can parse it into a date structure and then use simple comparison operators.
Not exactly as straight forward as you would think. Comparing a date with
another for less than or equality, you need to not only check the date, but
you have to take into consideration the times.
For example:
Dim date1 As DateTime = DateTime.Parse( "06/22/2005")
Dim date2 As DateTime = Now()
date1 is < date2...not equal to date2 :)
Mythran
Can the dates be converted into Ticks then compared?
--
Dennis in Houston
"Mythran" wrote: "Robin Tucker" <id************ *************@r eallyidont.com> wrote in message news:d9******** ***********@new s.demon.co.uk.. . what is the format of your filename date?
ie. is it file01032003.da t or something?
You can parse it into a date structure and then use simple comparison operators.
Not exactly as straight forward as you would think. Comparing a date with another for less than or equality, you need to not only check the date, but you have to take into consideration the times.
For example:
Dim date1 As DateTime = DateTime.Parse( "06/22/2005") Dim date2 As DateTime = Now()
date1 is < date2...not equal to date2 :)
Mythran
Mythran,
You can use DateTime.Date to "remove" the times:
Dim date1 As DateTime = DateTime.Parse( "06/22/2005")
Dim date2 As DateTime = Now()
Debug.WriteLine (date1.Date < date2.Date, "date1 < date2")
Alternatively you can simply use Today() if you want today's date, as
opposed to the current date & time.
Dim date1 As DateTime = DateTime.Parse( "06/22/2005")
Dim date2 As DateTime = Today()
Debug.WriteLine (date1 < date2, "date1 < date2")
Conversely you can use DateTime.TimeOf Day to remove the dates.
Dim time1 As TimeSpan = date1.TimeOfDay
Dim time2 As TimeSpan = date2.TimeOfDay
Debug.WriteLine (TimeSpan.Compa re(time1, time2) < 0, "time1 < time2")
Unfortunately we need to wait for VS.NET 2005 to use the overloaded <
operator on TimeSpan.
' VS.NET 2005 syntax
Debug.WriteLine (time1 < time2, "time1 < time2")
Hope this helps
Jay
"Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message
news:O$******** ******@TK2MSFTN GP10.phx.gbl...
|
| "Robin Tucker" <id************ *************@r eallyidont.com> wrote in
| message news:d9******** ***********@new s.demon.co.uk.. .
| > what is the format of your filename date?
| >
| > ie. is it file01032003.da t or something?
| >
| > You can parse it into a date structure and then use simple comparison
| > operators.
|
|
| Not exactly as straight forward as you would think. Comparing a date with
| another for less than or equality, you need to not only check the date,
but
| you have to take into consideration the times.
|
| For example:
|
| Dim date1 As DateTime = DateTime.Parse( "06/22/2005")
| Dim date2 As DateTime = Now()
|
| date1 is < date2...not equal to date2 :)
|
| Mythran
|
Tks for all replys ...
Rgds
JOhnny
"JFB" <he**@jfb.com > wrote in message
news:uV******** ******@TK2MSFTN GP12.phx.gbl... Hi All, I'm trying to find if a file name that includes the date is before todays to do some procedures. In my IF statement is working is just a few dates before but not is a year before. How can I fix this? Tks in advance... This is what I have: 'Set today's date
Dim todayDay As String
If Month(Now) < 10 Then todayDay = todayDay & "0" & Month(Now) Else todayDay = todayDay & Month(Now)
If Date.Today.Day < 10 Then todayDay = todayDay & "0" & Date.Today.Day Else todayDay = todayDay & Date.Today.Day
todayDay = todayDay & CStr(Year(Now). ToString)
'Get Files from Spool Folder
objFolder = dir.GetDirector yRoot(folderNam e)
colFiles = dir.GetFiles(fo lderName)
If colFiles(i).Sub string(colFiles (i).LastIndexOf ("\") + 1, 8) <= todayDay Then This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Abdullah Khaidar |
last post by:
I've read some language -include python- comparation texts
(benchmarks). But they are very old, so that I'm doubt about their
results. Does anyone know language comparation texts which compare
recent version of python -python 2.3- with some other languages?
M. Abdullah Khaidar
-- http://khaidarmak.blogspot.com
|
by: Lakrom |
last post by:
hello to all, i have this sql sentence Set xRs=pCon.Execute("SELECT
sum(monto_abono) AS TpuntosM FROM con_vtas WHERE RUTGTE='"&session("rut")&"'
and month("fecha")='#month("date")#'")
but this (month("fecha")='#month("date")#'") is correct?
the browser send me error "Error de compilación de Microsoft VBScript
(0x800A03EE)
Se esperaba ')'"
thank
--
Marco Antonio Artus S.
|
by: Greg Merideth |
last post by:
I have an XSL file that I am using to transform some XML data using this
method below. The problem is that if I use an embedded .XSL file in
the .NET assembly, I get an error indicating that the URI is invalid,
however if I open the file from the harddrive in the current directory,
it works.
Here's the method, notice that after s is loaded with the .xsl file from
the resource stream that if you do a messagebox.show with s.readtoend
you...
|
by: Steven Blair |
last post by:
Hi, I have a windows service monitoring a directory for files, which
works fine. The problem I have is when I pick up a file, it needs to be
the oldest file first.
Anyone any idea how to do this?
Regards,
Steven
|
by: Drew Berkemeyer |
last post by:
I've encounted a pretty strange problem and I'm not quite sure what to make
of it.
I have a web service that consumes an XML file as well as a few other
parameters. This web service works fine if I use the web test interface. It
also works fine if I call it from an ASP.NET page that has a text box where
the XML is pasted and then passed on. However, I get an exception if I use
an <input type="file"> control on the ASP page that allows...
| |
by: Peter |
last post by:
ASP.NET 1.1, this is a Intranet application and runs only on IE.
I have two webform text boxes which contain dates - starting date and ending
date. The dates could be in any format.
for example:
Starting date: 02/15/2006
Ending date: March 2006
I have to make sure the starting date is before the ending date
|
by: savigliano |
last post by:
hello, i am doing a date comparation and i have reallize that the data
i have in my database (general date format) it is causing me problems,
and because i don´t need the time data i would like to convert all the
general date data into short date format, so i would like to delete the
time part of the data, it is any way i can do that ????
Thank you in advance and sorry for my english
carlos
|
by: Grey |
last post by:
I have following problem:
table includes times for startup and end of operation as datetime field
related to daily shift operations:
dateid date starttime endtime
458 2006-12-29 22:00 23:15
458 2006-12-29 00:15 01:30
459 2006-12-30 20:00 21:10
|
by: Pemasem |
last post by:
In my register I have "06/10/2007 12:41:02" DateTime value, but my query :
SELECT Fecha
FROM dbo.WWW_LIBROVISITAS_VB
WHERE (Fecha <= '06/10/2007 12:41:02') AND (Fecha >= '05/10/2007')
ORDER BY Fecha DESC
Doesn't return it.
Why? Is not the same date?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |