Solved

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

Posted on 2007-04-10
2
594 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
2 Comments
 
LVL 17

Accepted Solution

by:
lem2802 earned 500 total points
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now