473,387 Members | 1,465 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,387 software developers and data experts.

Time calculation in windows application

92
Hai,

My windows application in C#.net should display time which
is also running like System time. And i hv to check time as morning 10.00AM to next day morning 10.00AM. if this happen it should clear the grid data and display new grid without value. How can i Do this?

Thanks in advance
Jun 23 '09 #1
9 3463
tlhintoq
3,525 Expert 2GB
Read up on DateTime object.

DateTime.Now

DateTime.Now.ToString("hh:mm tt");

Play a bit with that and come back with the code you create if you are still having issues.
Jun 23 '09 #2
Limno
92
@tlhintoq


Thanks for Replying me,

I hv display system time in textbox with the code

Expand|Select|Wrap|Line Numbers
  1. private void timer1_Tick(object sender, EventArgs e)
  2.         {
  3.             textBox1.Text = DateTime.Now.ToString("h:mm:ss tt");
  4.         }
  5.  
but i dont knw how to trigger event on specific time in c#.net

let say if time reaches 10.00AM it trigger tht event as refresh tht grid

reply me
Jun 23 '09 #3
tlhintoq
3,525 Expert 2GB
but i dont knw how to trigger event on specific time in c#.net
There isn't a pre-built event for that.
You will have to write your own.
Basically a set of 'if' conditions that you can put inside the Tick event is a good basic start. This will get you started for concept, but you'll need to beef it up.

Expand|Select|Wrap|Line Numbers
  1. If (DateTime.Now.Hours == AlarmTime.Hours)
  2. {
  3.    if (DateTime.Now.Minutes == AlarmTime.Minutes)
  4.    {
  5.       if (!RanToday) RaiseTodaysAlarmEvent();
  6.    }
  7. }
Jun 23 '09 #4
Limno
92
@tlhintoq

Can u explain me more. What's this code mean? i need to display data in datagridview with the sql query, it should check morning 10AM to next day 10AM. it displays the data in datagridview with this query and next day it should display new page. need to check with time and date.

Thanks in Advance
Jun 24 '09 #5
Curtis Rutland
3,256 Expert 2GB
So you're saying that you have a program that will be constantly running, and needs to have something happen every 24 hours?

You could use a timer and set the interval to 24 hours (86,400,000 ms). Subscribe to the timer's tick event and do your update there.
Jun 24 '09 #6
tlhintoq
3,525 Expert 2GB
@insertAlias
The problem with that is that if the something is supposed to happen every day at 10am, but the program is started at 1pm then repeats every 24hours....

Better to have a settable field for the time, then check to see if now is approximately equal to that time
Jun 24 '09 #7
Curtis Rutland
3,256 Expert 2GB
Yeah I forgot about the whole start time thing. There is probably an even better solution, like a refresh button, or closing the app when you are done, and opening it when it's time to use it.
Jun 24 '09 #8
tlhintoq
3,525 Expert 2GB
@insertAlias
User interaction seems to be contrary to the idea of automated server functions.

In my own apps I found it easiest to write a little component that is given a time like an alarm clock. At the appointed time it raises an 'AlarmEvent'. Whichever parts of the main application that are subscribed are welcome to do their thing when the alarm rings. Doesn't mater if its 1 piece, 100 pieces or no pieces, the alarm rings whether someone is listening or not. Much like my beside clock.

The alarm clock sits in my toolbar and is available to any program I need it in, just like a TextBox or any other control.
Jun 24 '09 #9
Curtis Rutland
3,256 Expert 2GB
@tlhintoq
I agree fully, however, the OP mentioned that it would be displaying data in a datagridview, which suggests to me that this isn't really a server app.
Jun 24 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
by: Terry | last post by:
I have used the code provided in the PreciseDateDiff function at the following Access Web link to calculate the time change date (from Daylight to Standard time and vice versa): ...
5
by: Tom | last post by:
A field in a data set I want to import into Access is in Unix time (seconds from a certain time on a certain date). Does anyone know the precise date and the precise time on that date that Unix is...
2
by: Quina | last post by:
Hi there, i'm building an windows application to manage my disc collection. I also want to enable it with cd recognition features on audio CDs. In order to do this I must submit the CD info...
33
by: ram.ragu | last post by:
hi i have problem to calculate idle time of cpu and if idle time is more then i have to shut down the system. can anyone tell me the idea to so that please
8
by: andreas | last post by:
Hi, I have a calculation program in vb.net who is running for let us say for more than a hour. When I will do meanwhile something els in a office program I see that my calculation program takes a...
3
by: Satish Itty | last post by:
Hi all, I have a big problem in my hands and not sure how I can fix this. Any suggestions would be greatly appreciated. I have a .NET 3 tier app developed in VS2003 and .NET 1.1. the client is a...
6
by: Lara1 | last post by:
I'm trying to get certain cells to show a hovering alert message when I click on them. (I don't want an error-message style box to pop up, because I'll eventually want it to show for lots of cells...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.