Just assign the data for date of entry taken from the database and assign it to a DateTime variable in this case
timePosted. The code will add an hour to this and compare it to the current time and if the date of entry plus an hour is greater than the current time it will run the code contained withinn the if statement.
if (timePosted.AddHours(1) > DateTime.Now)
{
// Show the data...
}
newonehere69
Member
64 Points
83 Posts
One Hour Delay Display
Dec 21, 2012 01:16 PM|LINK
Hi,
I will like to know how I can delay the display of data for one hour using ASP.Net and C#.
Any examples or tutorial will be appreciated.
Thanks.
Careed
All-Star
18764 Points
3637 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:19 PM|LINK
You will clarify further as to what you really want to, as you have some issues with this length of time for a web-based application.
"The oxen are slow, but the earth is patient."
jprochazka
Contributor
4846 Points
740 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:23 PM|LINK
When you add the data add the date and time it was posted using:
Then when displaying data compare this DateTime plus one hour with the current DateTime:
if (timePosted.AddHours(1) > DateTime.Now) { // Show the data... }Edit:
Fixed a mess up in originally posted code...
newonehere69
Member
64 Points
83 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:24 PM|LINK
Hi,
One hour delay for the data to be displayed on the web app.
The data comes from a sql db using a stored procedure.
How can I accomplished this if its possible. Any other suggestions are welcome.
The data must not be displayed for an hour.
newonehere69
Member
64 Points
83 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:30 PM|LINK
Thanks for your reply.
I just found out there is a field on a table for date of entry.
How will I modify your example to use the date field from the table?
Thanks again.
jprochazka
Contributor
4846 Points
740 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:33 PM|LINK
Just assign the data for date of entry taken from the database and assign it to a DateTime variable in this case timePosted. The code will add an hour to this and compare it to the current time and if the date of entry plus an hour is greater than the current time it will run the code contained withinn the if statement.
if (timePosted.AddHours(1) > DateTime.Now) { // Show the data... }newonehere69
Member
64 Points
83 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:36 PM|LINK
Thanks. Going to try it.
jprochazka
Contributor
4846 Points
740 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:36 PM|LINK
I should have added you can do this in your SQL as well which would possibly be a better approach:
newonehere69
Member
64 Points
83 Posts
Re: One Hour Delay Display
Dec 21, 2012 01:47 PM|LINK
I agree. Since everything is done in the stored procedure. The web app just displays the data with a few conditions.
Thanks again, I really apprecited.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: One Hour Delay Display
Dec 22, 2012 02:56 AM|LINK
Hi,
I come here to check whether your problem is solved or not.
If yes, I'll mark answers to close the issue.
Or just feedback freely.