473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

datetime

I am tyrying to use the System.IO.File.GetCreationTime
name space to get the creation date of a file. That's no
problem.

I want to delete a file if it is older than two weeks.

For Each File1 In Directory.GetFiles("c:\Test")
If CreationDate < (System.DateTime.Now( ) - 14) Then
File.Delete(File1)
End If
Next

my error is at (system.datetime.now() - 14)

says operator '-' is not defined for datetime or integer.

Does anyone know how to subtract a number of days from a
date that is not in datetime format?

Thanks
Nov 18 '05 #1
2 2815
Hi Brian,

Try:
If System.DateTime.Now.Subtract(CreationDate).Days > 14

Alex Papadimoulis

"BRIAN" <bs******@lbrspec.com> wrote in message
news:10*****************************@phx.gbl...
I am tyrying to use the System.IO.File.GetCreationTime
name space to get the creation date of a file. That's no
problem.

I want to delete a file if it is older than two weeks.

For Each File1 In Directory.GetFiles("c:\Test")
If CreationDate < (System.DateTime.Now( ) - 14) Then
File.Delete(File1)
End If
Next

my error is at (system.datetime.now() - 14)

says operator '-' is not defined for datetime or integer.

Does anyone know how to subtract a number of days from a
date that is not in datetime format?

Thanks

Nov 18 '05 #2
Hi,
Try using DateTime class. It has methods like Add Days. try adding in -14 to
now and then compare it with CreationDate.

Chao,
Hermit Dave

"BRIAN" <bs******@lbrspec.com> wrote in message
news:10*****************************@phx.gbl...
I am tyrying to use the System.IO.File.GetCreationTime
name space to get the creation date of a file. That's no
problem.

I want to delete a file if it is older than two weeks.

For Each File1 In Directory.GetFiles("c:\Test")
If CreationDate < (System.DateTime.Now( ) - 14) Then
File.Delete(File1)
End If
Next

my error is at (system.datetime.now() - 14)

says operator '-' is not defined for datetime or integer.

Does anyone know how to subtract a number of days from a
date that is not in datetime format?

Thanks

Nov 18 '05 #3

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

Similar topics

4
by: Max M | last post by:
# -*- coding: latin-1 -*- """ I am currently using the datetime package, but I find that the design is oddly asymmetric. I would like to know why. Or perhaps I have misunderstood how it...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
3
by: Andrew S. Giles | last post by:
Hello, I am importing a flat text file, and putting it into a datagrid for display on a form. Currently the users have their dates and times seperated. I have two fields, therefore in the...
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
5
by: I am Sam | last post by:
I have created this DateTime object and instanced it I think correctly DateTime myClubNow1=new...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
1
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...
0
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.