473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dates

I have a lot of files in a folder. The files are created on different dates.
Some of the files have been created on the same date. I need to build an
array with unique dates. So if 5 files have the same "created date" I only
need one date in the array.

5 files created on 22.05.2004
3 files created on 28.05.2004
will result in an array with 2 dates
(in the array 22052005 and 28052004)

Have been struggling with this for a week now so any code that could help
would be like x-mas :-)
Best regards
Trond
Nov 16 '05 #1
4 1184
Trond Hoiberg <th******@broadpark.no> wrote:
I have a lot of files in a folder. The files are created on different dates.
Some of the files have been created on the same date. I need to build an
array with unique dates. So if 5 files have the same "created date" I only
need one date in the array.


Here're a couple of hints:

o Use ArrayList.
o Check if the ArrayList already Contains[*] the value before adding it.

If you're still stuck, post your attempts here, and someone can then point
out any mistakes you've made.
[*] That was a hint within a hint. :-)
Nov 16 '05 #2
Trond,

I would just use a hashtable. Basically, cycle through all of the
files, and add the value to the hashtable. The key is the date of the file,
while the value can be anything (I usually use booleans).

Then, you can get the Keys property on the hashtable, and it will have a
unique list of the dates that are the keys in the hashtable.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Trond Hoiberg" <th******@broadpark.no> wrote in message
news:41******@news.broadpark.no...
I have a lot of files in a folder. The files are created on different
dates. Some of the files have been created on the same date. I need to
build an array with unique dates. So if 5 files have the same "created
date" I only need one date in the array.

5 files created on 22.05.2004
3 files created on 28.05.2004
will result in an array with 2 dates
(in the array 22052005 and 28052004)

Have been struggling with this for a week now so any code that could help
would be like x-mas :-)
Best regards
Trond

Nov 16 '05 #3
I actually wouldn't use an ArrayList, as the Contains method would cycle
through each element in the array (and the more unique elements there are,
the longer it will take). A Hashtable would be much, much quicker
(overall).

The concept is the same though.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"C# Learner" <cs****@learner.here> wrote in message
news:1a****************@csharp.learner...
Trond Hoiberg <th******@broadpark.no> wrote:
I have a lot of files in a folder. The files are created on different
dates.
Some of the files have been created on the same date. I need to build an
array with unique dates. So if 5 files have the same "created date" I
only
need one date in the array.


Here're a couple of hints:

o Use ArrayList.
o Check if the ArrayList already Contains[*] the value before adding it.

If you're still stuck, post your attempts here, and someone can then point
out any mistakes you've made.

[*] That was a hint within a hint. :-)

Nov 16 '05 #4
OK, thanks. As i said i'm a newbee so i guess i still have to try to fig it
out myself :-)
I have tried with various collections but i dont get it right. Thats why i
hoped someone had some code that could help me out.
Best regards
Trond

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ew**************@TK2MSFTNGP14.phx.gbl...
Trond,

I would just use a hashtable. Basically, cycle through all of the
files, and add the value to the hashtable. The key is the date of the
file, while the value can be anything (I usually use booleans).

Then, you can get the Keys property on the hashtable, and it will have
a unique list of the dates that are the keys in the hashtable.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Trond Hoiberg" <th******@broadpark.no> wrote in message
news:41******@news.broadpark.no...
I have a lot of files in a folder. The files are created on different
dates. Some of the files have been created on the same date. I need to
build an array with unique dates. So if 5 files have the same "created
date" I only need one date in the array.

5 files created on 22.05.2004
3 files created on 28.05.2004
will result in an array with 2 dates
(in the array 22052005 and 28052004)

Have been struggling with this for a week now so any code that could help
would be like x-mas :-)
Best regards
Trond


Nov 16 '05 #5

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

Similar topics

8
by: Riley | last post by:
The date fields being saved by a VB program were being saved as #2003-11-22#. For reasons unknown to me these dates began to be saved as "11/22/2003" All of these dates were made dates with the...
7
by: Alistair | last post by:
diary_date = request.form("diary_date") - (from a populated drop down list) strSQL = "SELECT saz_title, saz_text from saz_details where saz_date =#" & diary_date & "#" a response.write...
5
by: PW | last post by:
<rant> Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this...
10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
1
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from...
2
by: Rachel Suddeth | last post by:
Is there a way to have the non-selectable dates (those before MinDate and after MaxDate) draw differently so my users can see right away what dates aren't allowed? I'm not seeing it... ...
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
1
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie...
7
by: evilcowstare via AccessMonster.com | last post by:
Hi, I have searched the forum for answers on this and to be honest as a novice I find it a bit confusing so apologies if it is simple. There are some searches that I want to apply to my database....
2
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.