0

I am developing a window service in which i am downloading some files from a server according to the date and as soon as date changes I want the variables to be reset to the default values.

I am trying to do like this:

if (DateTime.Now.ToString("HHmmsstt").Contains("000000AM"))
{
      reset variables
}

I am having a variable which counts the no. of files I dowloaded in a day. Now as soon as date changes, i want this variable to be reset to 0. So I applied this condition but this do not work as it is not necessary that when i am comparing ,time is 12 o clock

Ke7in
  • 917
  • 2
  • 7
  • 16
  • I don't understand your question. Can you please clarify it? Your if statement works only if local datetime is midnight in your case. – Soner Gönül Jun 23 '14 at 11:18
  • Yes I want that only but the thing is comparison is not necessarily takes place at midnight.It can go 2 sec up or more – Ke7in Jun 23 '14 at 11:32

1 Answers1

0

You will need to save the last time you checked. If your date (00:00:00 AM) is between the last time and this time, you need to reset your variables.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • Thanks for answer , Let me assume that LastTimeChecked : 115859PM ,NewTimeChecked :020202AM, How can I check that 000000AM comes in between. Ok i Get it http://stackoverflow.com/questions/12998739/how-to-check-if-datetime-now-is-between-two-given-datetimes-for-time-part-only – Ke7in Jun 23 '14 at 11:22