473,403 Members | 2,293 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,403 software developers and data experts.

Q: Hours

Hi

I'm hoping that somebody can help me with the following question.

I have a DataView which contains a column which contains a Time.

I would like to create an array which will store the times within one hour.
For example, all the times between 12:00 and 13:00 will be placed in one
index of the array, all the calls from 13:00 to 14:00 will be placed in the
next.

Can anybody give me some code to do this?

Thanks in advance

Geoff
Nov 16 '05 #1
10 1310
Geoff,
Just out of curiosity, why have you moved to the
microsoft.public.dotnet.languages.csharp newsgroup?

Do you really want this part in csharp or would you like VB.NET like the
rest has been?

Can you define a little better what "all the times between" means? Do you
mean all the DataRows that fall within that time frame or ever minute
(outside of the rows) that falls within that range?

Just curious
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

I'm hoping that somebody can help me with the following question.

I have a DataView which contains a column which contains a Time.

I would like to create an array which will store the times within one hour. For example, all the times between 12:00 and 13:00 will be placed in one
index of the array, all the calls from 13:00 to 14:00 will be placed in the next.

Can anybody give me some code to do this?

Thanks in advance

Geoff

Nov 16 '05 #2
Hi Jay

VB has been put on hold for now. I'm trying to work on some C# now (oh joy!)
LOL

Sorry I didn't make the original post very clear. Suppose I have a list of
dates as follows:

15:02, 09:23, 14:34, 17:02, 15:45, etc.

These would be in order i.e. each one would have its own unique identifier
in terms of order e.g. 15:02 is 1, 09:23 is 2 etc.

I'd like to be able to create an array that would, for example, have:

index 0 having all the items in the list with times from 01:00 to 02:00 (but
not including)
index 1 having all the items in the list with times from from 02:00 to 03:00
(but not including)

etc.

Interested in hearing your thoughts

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl...
Geoff,
Just out of curiosity, why have you moved to the
microsoft.public.dotnet.languages.csharp newsgroup?

Do you really want this part in csharp or would you like VB.NET like the
rest has been?

Can you define a little better what "all the times between" means? Do you
mean all the DataRows that fall within that time frame or ever minute
(outside of the rows) that falls within that range?

Just curious
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

I'm hoping that somebody can help me with the following question.

I have a DataView which contains a column which contains a Time.

I would like to create an array which will store the times within one

hour.
For example, all the times between 12:00 and 13:00 will be placed in one
index of the array, all the calls from 13:00 to 14:00 will be placed in

the
next.

Can anybody give me some code to do this?

Thanks in advance

Geoff


Nov 16 '05 #3
Geoff Jones wrote:
Hi

I'm hoping that somebody can help me with the following question.

I have a DataView which contains a column which contains a Time.

I would like to create an array which will store the times within one hour.
For example, all the times between 12:00 and 13:00 will be placed in one
index of the array, all the calls from 13:00 to 14:00 will be placed in the
next.

Can anybody give me some code to do this?


That is the simplest thing in the world.

Read an article or two and you'll have it.
Nov 16 '05 #4
Geoff,
I would use an array of arrays or an array of ArrayLists.

I would expect index 0 be from midnight to 1:00?

Then you can simply use the hour of the Time (DateTime.Hour) as your index,
and use ArrayList.Add to add the time to that row...

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi Jay

VB has been put on hold for now. I'm trying to work on some C# now (oh joy!) LOL

Sorry I didn't make the original post very clear. Suppose I have a list of
dates as follows:

15:02, 09:23, 14:34, 17:02, 15:45, etc.

These would be in order i.e. each one would have its own unique identifier
in terms of order e.g. 15:02 is 1, 09:23 is 2 etc.

I'd like to be able to create an array that would, for example, have:

index 0 having all the items in the list with times from 01:00 to 02:00 (but not including)
index 1 having all the items in the list with times from from 02:00 to 03:00 (but not including)

etc.

Interested in hearing your thoughts

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl...
Geoff,
Just out of curiosity, why have you moved to the
microsoft.public.dotnet.languages.csharp newsgroup?

Do you really want this part in csharp or would you like VB.NET like the
rest has been?

Can you define a little better what "all the times between" means? Do you mean all the DataRows that fall within that time frame or ever minute
(outside of the rows) that falls within that range?

Just curious
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

I'm hoping that somebody can help me with the following question.

I have a DataView which contains a column which contains a Time.

I would like to create an array which will store the times within one

hour.
For example, all the times between 12:00 and 13:00 will be placed in one index of the array, all the calls from 13:00 to 14:00 will be placed
in the
next.

Can anybody give me some code to do this?

Thanks in advance

Geoff



Nov 16 '05 #5
That helps a lot. Thanks Jay

As you can gather, I'm very new to programming. Your help and others is
invaluable during my steep learning curve.

One question that occurs to me now how to tell the ListArray what values I
need to store. I know for an array this can be done as:

Dim x() As Integer

However, and forgive me if this is wrong, I set up an array of an ListArray
by

Dim y() As ListArray

but that doesn't say if it holds strings, doubles or integers etc.

Can you help?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...
Geoff,
I would use an array of arrays or an array of ArrayLists.

I would expect index 0 be from midnight to 1:00?

Then you can simply use the hour of the Time (DateTime.Hour) as your index, and use ArrayList.Add to add the time to that row...

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi Jay

VB has been put on hold for now. I'm trying to work on some C# now (oh

joy!)
LOL

Sorry I didn't make the original post very clear. Suppose I have a list of
dates as follows:

15:02, 09:23, 14:34, 17:02, 15:45, etc.

These would be in order i.e. each one would have its own unique identifier in terms of order e.g. 15:02 is 1, 09:23 is 2 etc.

I'd like to be able to create an array that would, for example, have:

index 0 having all the items in the list with times from 01:00 to 02:00

(but
not including)
index 1 having all the items in the list with times from from 02:00 to

03:00
(but not including)

etc.

Interested in hearing your thoughts

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:eB**************@TK2MSFTNGP09.phx.gbl...
Geoff,
Just out of curiosity, why have you moved to the
microsoft.public.dotnet.languages.csharp newsgroup?

Do you really want this part in csharp or would you like VB.NET like the rest has been?

Can you define a little better what "all the times between" means? Do

you mean all the DataRows that fall within that time frame or ever minute
(outside of the rows) that falls within that range?

Just curious
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
> Hi
>
> I'm hoping that somebody can help me with the following question.
>
> I have a DataView which contains a column which contains a Time.
>
> I would like to create an array which will store the times within one hour.
> For example, all the times between 12:00 and 13:00 will be placed in one > index of the array, all the calls from 13:00 to 14:00 will be placed in the
> next.
>
> Can anybody give me some code to do this?
>
> Thanks in advance
>
> Geoff
>
>



Nov 16 '05 #6
Geoff,
but that doesn't say if it holds strings, doubles or integers etc. ArrayList holds objects, when you take a value out you need to cast the
value to the specific type you put in.

If you want strongly typed, either use pure arrays, either:

Dim y()() As DateTime ' Array of Arrays of DateTime

Dim x(,) As DateTime ' 2 dimensional

The "problem" with both of these is that both dimensions are "fixed",
System.Collections.ArrayList is dynamic, in that you can add elements to it.

If you want a strongly typed "ArrayList" you can inherit from
System.Collections.CollectionBase and create a strongly typed list.

NOTE: VS.NET 2005 (.NET 2.0) (Whidbey) due out sometime next year, will
support Generics so it will be easier to get an array of list of datetime...

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. . That helps a lot. Thanks Jay

As you can gather, I'm very new to programming. Your help and others is
invaluable during my steep learning curve.

One question that occurs to me now how to tell the ListArray what values I
need to store. I know for an array this can be done as:

Dim x() As Integer

However, and forgive me if this is wrong, I set up an array of an ListArray by

Dim y() As ListArray

but that doesn't say if it holds strings, doubles or integers etc.

Can you help?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...
Geoff,
I would use an array of arrays or an array of ArrayLists.

I would expect index 0 be from midnight to 1:00?

Then you can simply use the hour of the Time (DateTime.Hour) as your

index,
and use ArrayList.Add to add the time to that row...

Hope this helps
Jay

<<snip>>
Nov 16 '05 #7
Ah, ok, it is because you can put anything in? Like an STL vector?

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
That helps a lot. Thanks Jay

As you can gather, I'm very new to programming. Your help and others is
invaluable during my steep learning curve.

One question that occurs to me now how to tell the ListArray what values I
need to store. I know for an array this can be done as:

Dim x() As Integer

However, and forgive me if this is wrong, I set up an array of an ListArray by

Dim y() As ListArray

but that doesn't say if it holds strings, doubles or integers etc.

Can you help?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...
Geoff,
I would use an array of arrays or an array of ArrayLists.

I would expect index 0 be from midnight to 1:00?

Then you can simply use the hour of the Time (DateTime.Hour) as your index,
and use ArrayList.Add to add the time to that row...

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi Jay

VB has been put on hold for now. I'm trying to work on some C# now (oh

joy!)
LOL

Sorry I didn't make the original post very clear. Suppose I have a list of
dates as follows:

15:02, 09:23, 14:34, 17:02, 15:45, etc.

These would be in order i.e. each one would have its own unique identifier in terms of order e.g. 15:02 is 1, 09:23 is 2 etc.

I'd like to be able to create an array that would, for example, have:

index 0 having all the items in the list with times from 01:00 to
02:00
(but
not including)
index 1 having all the items in the list with times from from 02:00 to

03:00
(but not including)

etc.

Interested in hearing your thoughts

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:eB**************@TK2MSFTNGP09.phx.gbl...
> Geoff,
> Just out of curiosity, why have you moved to the
> microsoft.public.dotnet.languages.csharp newsgroup?
>
> Do you really want this part in csharp or would you like VB.NET like the > rest has been?
>
> Can you define a little better what "all the times between" means?
Do you
> mean all the DataRows that fall within that time frame or ever
minute > (outside of the rows) that falls within that range?
>
> Just curious
> Jay
>
> "Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
> news:40*********************@news.dial.pipex.com.. .
> > Hi
> >
> > I'm hoping that somebody can help me with the following question.
> >
> > I have a DataView which contains a column which contains a Time.
> >
> > I would like to create an array which will store the times within

one > hour.
> > For example, all the times between 12:00 and 13:00 will be placed

in one
> > index of the array, all the calls from 13:00 to 14:00 will be
placed in
> the
> > next.
> >
> > Can anybody give me some code to do this?
> >
> > Thanks in advance
> >
> > Geoff
> >
> >
>
>



Nov 16 '05 #8
Jay

One final question

I've tried the following just to test a few ideas:

Dim x(10) As ArrayList

x(0).Add(7)

Debug.WriteLine(CInt(x(0).Item(0))

thinking that this would print the integer 7.

However, I get an exception i.e. Object reference not set to an instance of
an object

Hope you can help.

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u0**************@TK2MSFTNGP11.phx.gbl...
Geoff,
but that doesn't say if it holds strings, doubles or integers etc. ArrayList holds objects, when you take a value out you need to cast the
value to the specific type you put in.

If you want strongly typed, either use pure arrays, either:

Dim y()() As DateTime ' Array of Arrays of DateTime

Dim x(,) As DateTime ' 2 dimensional

The "problem" with both of these is that both dimensions are "fixed",
System.Collections.ArrayList is dynamic, in that you can add elements to

it.
If you want a strongly typed "ArrayList" you can inherit from
System.Collections.CollectionBase and create a strongly typed list.

NOTE: VS.NET 2005 (.NET 2.0) (Whidbey) due out sometime next year, will
support Generics so it will be easier to get an array of list of datetime...
Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
That helps a lot. Thanks Jay

As you can gather, I'm very new to programming. Your help and others is
invaluable during my steep learning curve.

One question that occurs to me now how to tell the ListArray what values I need to store. I know for an array this can be done as:

Dim x() As Integer

However, and forgive me if this is wrong, I set up an array of an

ListArray
by

Dim y() As ListArray

but that doesn't say if it holds strings, doubles or integers etc.

Can you help?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:uz**************@TK2MSFTNGP11.phx.gbl...
Geoff,
I would use an array of arrays or an array of ArrayLists.

I would expect index 0 be from midnight to 1:00?

Then you can simply use the hour of the Time (DateTime.Hour) as your

index,
and use ArrayList.Add to add the time to that row...

Hope this helps
Jay

<<snip>>

Nov 16 '05 #9
Geoff,
Doh!

I forgot to mention you need to initialize each element of your array as
ArrayList is a reference type.

For index As Integer = 0 to 10
x(index) = New ArrayList()
Next

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Jay

One final question

I've tried the following just to test a few ideas:

Dim x(10) As ArrayList

x(0).Add(7)

Debug.WriteLine(CInt(x(0).Item(0))

thinking that this would print the integer 7.

However, I get an exception i.e. Object reference not set to an instance of an object

Hope you can help.

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u0**************@TK2MSFTNGP11.phx.gbl...
Geoff,
but that doesn't say if it holds strings, doubles or integers etc. ArrayList holds objects, when you take a value out you need to cast the
value to the specific type you put in.

If you want strongly typed, either use pure arrays, either:

Dim y()() As DateTime ' Array of Arrays of DateTime

Dim x(,) As DateTime ' 2 dimensional

The "problem" with both of these is that both dimensions are "fixed",
System.Collections.ArrayList is dynamic, in that you can add elements to

it.

If you want a strongly typed "ArrayList" you can inherit from
System.Collections.CollectionBase and create a strongly typed list.

NOTE: VS.NET 2005 (.NET 2.0) (Whidbey) due out sometime next year, will
support Generics so it will be easier to get an array of list of

datetime...

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
That helps a lot. Thanks Jay

As you can gather, I'm very new to programming. Your help and others is invaluable during my steep learning curve.

One question that occurs to me now how to tell the ListArray what
values I need to store. I know for an array this can be done as:

Dim x() As Integer

However, and forgive me if this is wrong, I set up an array of an

ListArray
by

Dim y() As ListArray

but that doesn't say if it holds strings, doubles or integers etc.

Can you help?

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:uz**************@TK2MSFTNGP11.phx.gbl...
> Geoff,
> I would use an array of arrays or an array of ArrayLists.
>
> I would expect index 0 be from midnight to 1:00?
>
> Then you can simply use the hour of the Time (DateTime.Hour) as your
index,
> and use ArrayList.Add to add the time to that row...
>
> Hope this helps
> Jay
>

<<snip>>


Nov 16 '05 #10
Thanks Jay. It works a treat!

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Geoff,
Doh!

I forgot to mention you need to initialize each element of your array as
ArrayList is a reference type.

For index As Integer = 0 to 10
x(index) = New ArrayList()
Next

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Jay

One final question

I've tried the following just to test a few ideas:

Dim x(10) As ArrayList

x(0).Add(7)

Debug.WriteLine(CInt(x(0).Item(0))

thinking that this would print the integer 7.

However, I get an exception i.e. Object reference not set to an instance

of
an object

Hope you can help.

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u0**************@TK2MSFTNGP11.phx.gbl...
Geoff,
> but that doesn't say if it holds strings, doubles or integers etc.
ArrayList holds objects, when you take a value out you need to cast the value to the specific type you put in.

If you want strongly typed, either use pure arrays, either:

Dim y()() As DateTime ' Array of Arrays of DateTime

Dim x(,) As DateTime ' 2 dimensional

The "problem" with both of these is that both dimensions are "fixed",
System.Collections.ArrayList is dynamic, in that you can add elements to
it.

If you want a strongly typed "ArrayList" you can inherit from
System.Collections.CollectionBase and create a strongly typed list.

NOTE: VS.NET 2005 (.NET 2.0) (Whidbey) due out sometime next year,

will support Generics so it will be easier to get an array of list of

datetime...

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
> That helps a lot. Thanks Jay
>
> As you can gather, I'm very new to programming. Your help and others

is > invaluable during my steep learning curve.
>
> One question that occurs to me now how to tell the ListArray what

values
I
> need to store. I know for an array this can be done as:
>
> Dim x() As Integer
>
> However, and forgive me if this is wrong, I set up an array of an
ListArray
> by
>
> Dim y() As ListArray
>
> but that doesn't say if it holds strings, doubles or integers etc.
>
> Can you help?
>
> Geoff
>
> "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in

message
> news:uz**************@TK2MSFTNGP11.phx.gbl...
> > Geoff,
> > I would use an array of arrays or an array of ArrayLists.
> >
> > I would expect index 0 be from midnight to 1:00?
> >
> > Then you can simply use the hour of the Time (DateTime.Hour) as your > index,
> > and use ArrayList.Add to add the time to that row...
> >
> > Hope this helps
> > Jay
> >
<<snip>>



Nov 16 '05 #11

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

Similar topics

3
by: George | last post by:
Hi, The sql query below returns data in the 'note' field from a table called ww_rec_1 from the previous month and displays the sum of hours for each category. SELECT note,SUM(hours)FROM...
14
by: anon | last post by:
Does anyone know how many man-hours were used in creating .NET 1.0? I thought it would be an interesting statistic to know. Thanks.
5
by: mitchchristensen | last post by:
I have a transaction log that tracks issues from a call center. Each time an issue is assigned to someone else, closed, etc. I get a time stamp. I have these time stamps for the beginning of an...
5
by: Rebecca Smith | last post by:
I'm building log book to keep track of a racers stats during a long ultra marathon race. Things such as time on the bike, time off, H20 intake, electrolytes and the like. When I say long I mean...
1
by: serge | last post by:
Right now the database I am working with is storing time in an Integer data type and is storing the time value in seconds. The application does not allow entering seconds. It accepts minutes and...
22
by: Drum2001 | last post by:
I have a table that tracks employee times. I have a column (Date/Time). Users, through a form, enter how long it takes them to complete a task. For example, 03:45 = 3 hours and 45 mins. I am...
1
by: Brett | last post by:
Does anyone know how to calculate hours that go over 24? I am tracking how many hours & seconds our production keyers work everyday. When I run a query for a length of time that a given employee...
6
by: richbneal | last post by:
I really like the site so far and this is my first post. I have looked through some of the archives with no luck. I have also read the posting guidelines and will do my best to be clear and accurate...
3
by: sentiald | last post by:
I am having trouble with the following code. I need to have it calculate regular pay, overtime pay and gross pay and display it back to the user. Can anyone figure out where my problem lies. <?php...
1
by: 22dude | last post by:
it says the variable hours is being used with out being initializes i am using C++ 2005 express edition , I am currently student Please help me out to find the solution on my code below #...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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,...
0
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
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...
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,...
0
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...

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.