Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP .NET C# Show Only Hourly DateTime values from an Array of 24 hour values.

Posted on 2007-04-11
5
Medium Priority
?
800 Views
Last Modified: 2010-07-27
Someone tried to answer this question yesterday but that solution did not work. I am reposting it. Looks like no one has a solution to my question (even in other forums outside of EExchange). So here we go again. The output of the response.write can be seen in:
http://www.cameradisplay.com/CondorStats/tempdisplaytime.htm

These are 360 different time values, spanning 24 hours, separated from each other by 4 minutes. How can I just show these values in separated by Hourly spans while the intermediate values simply get replaced by blank space (the chart's X-Axis cannot accomodate all 360 values).

 DateTime startTime = Convert.ToDateTime(dayArray[0]);
                DateTime endTime = Convert.ToDateTime(dayArray[dayArray.Length - 2]);
                TimeSpan timeSpan = (endTime - startTime);
                //Response.Write(startTime.ToString() + " " + endTime.ToString() + " " + timeSpan.ToString());
                for (int i = 0; i < dayArray.Length - 2; i++)//loop to one less because of extra comma/space at end
                {
                    DateTime currentTime = Convert.ToDateTime(dayArray[i]);
                    Response.Write(currentTime.ToString() + "<br>");

                }
0
Comment
Question by:irfantak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 2000 total points
ID: 18892965
Since they are separated by 4 minutes, you should (I am not quite clear on what you want) either
only do a Response.Write every 15 values (for example, if
(i % 15) == 0
) or do either a Response.Write with the time string or a Response.Write of a blank space depending on whether
(i % 15) == 0
(or some such value).
0
 

Author Comment

by:irfantak
ID: 18893088
Thanks.
Here is what I am trying to do: Replicate the following chart and the code above builds the X-Axis of the chart: http://central.condor.clemson.edu/public/condor-stats/Hour.html

Basically, there are 360 data values which cannot fit on X-axis and so I only need to show values which are 1+ hours apart on X-axis.
But the X-axis does need to have some filler/empty data so that the x-axis can build (corresponding to y-axis values) except that the display data on x-axis will be a few date/time values.

Makes sense?
Thanks.
0
 

Author Comment

by:irfantak
ID: 18893194
Hey, your solution was so simple but I have made good progress. Will be back! Thanks!
0
 

Author Comment

by:irfantak
ID: 18893220
Yes, it works. Thanks! Now I have to figure out data for 'Weekly' and 'Monthly' charts...But that is for another time.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 18893398
If the concept is the same, but the constant is different your life will be easy!
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question