Solved

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

Posted on 2007-04-10
2
636 Views
Last Modified: 2012-06-22
Asp .net C#. Show only date/time values from a 24 hour period which are 3 hours apart. In the following code, dayArray has 360 date/time values. Each value is 4 minutes apart from the other ones. You can see the output of Response.Write in the following page: www.cameradisplay.com/CondorStats/TempDisplayTime.htm

So how I do I just show DateTime values like starting from the very first DateTime value to the next 1 hour DateTime value, and then the next 1 hour, until the end of all 24 hour values?

-------------------------
string[] dayArray = formatData.ToString().Split(new char[] { ',' });//split to create array
                             for (int i = 0; i < (dayArray.Length - 1); i++)
                {
                    DateTime curTime = Convert.ToDateTime(dayArray[i]);
                    DateTime displayTime = curTime.AddHours(3);
                    Response.Write(curTime + "<BR>");
                  //will show the ouput as //in www.cameradisplay.com/CondorStats/TempDisplayTime.htm
                }
----------------------------------------------------
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
2 Comments
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 500 total points
ID: 18884650
something like this???
DateTime d = DateTime.Now;
                for (int i = 0; 24-d.Hour; i++)
                {
                    d.AddHour(1)
                    Response.Write(d.ToString()+ "<BR>");
                  //will show the ouput as //in www.cameradisplay.com/CondorStats/TempDisplayTime.htm
                }
0
 

Author Comment

by:irfantak
ID: 18884703
Thanks. Nah, not sure what your code is--DateTime.Now does not apply to my code--there is already a set of Date/Time values spanning 24 hours.. Okay, here is the current online output:

http://www.cameradisplay.com/CondorStats/CondorMachineStats.aspx?period=Day&chartenv=sl

and the code is

 string[] dayArray = formatData.ToString().Split(new char[] { ',' });
                for (int i = 0; i < (dayArray.Length - 1); i++)//because of the extra , at the end, loop to one less
                {
                    DateTime curTime = Convert.ToDateTime(dayArray[i]);
                    Response.Write(curTime + "<br>");

                }
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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