473,769 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file date comparation

JFB
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


Nov 21 '05 #1
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

Nov 21 '05 #2
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

Nov 21 '05 #3
JFB
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

Nov 21 '05 #4
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


Nov 21 '05 #5

"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

Nov 21 '05 #6
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

Nov 21 '05 #7
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
|
Nov 21 '05 #8
JFB
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

Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1298
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
6
1490
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.
2
2153
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...
1
1220
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
7
2674
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...
3
2591
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
2
7010
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
8
2880
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
3
1214
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?
0
9589
marktang
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...
0
10050
jinu1996
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...
1
9999
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,...
0
9866
tracyyun
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...
0
8876
agi2029
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...
1
7413
isladogs
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...
0
5310
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.