Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7277863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:47:54+00:00 2026-05-28T22:47:54+00:00

date[inc] = [0] = 01/01/2011 dateTimePicker1.Value = {01/01/2011 00:00:00} The if condition is never

  • 0

date[inc] = [0] = "01/01/2011"

dateTimePicker1.Value = {01/01/2011 00:00:00}

The if condition is never fulfilled when changing a secondary datetimepicker. The first datetimepicker has to be changed once before this code will work. This code is triggered by a ValueChanged in both cases.

Any ideas?

Edit:

int start;
int inc = 0;
while (true)
{
   inc++;
   if (Convert.ToString(dateTimePicker1.Value.ToShortDateString()) == date[inc])
   {
      start = inc;
      inc = 0;
      break;
   }  
}

=/=

int start;
int inc = 0;
while (true)
{
   if (Convert.ToString(dateTimePicker1.Value.ToShortDateString()) == date[inc])
   {
      start = inc;
      inc = 0;
      break;
   }  
   inc++;
}

Still very helpful comments, thanks everyone. Obviously was missing the first date because of an increment, causing an infinite loop.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:47:54+00:00Added an answer on May 28, 2026 at 10:47 pm

    Try to compare like this

    if (dateTimePicker1.Value.ToString("MM/dd/yyyy",
           new System.Globalization.CultureInfo("en-US") == date[inc])
    

    OR

    //Considering your date format is MM/dd/yyyy, coz 01/01/2011 doesn't help in uderstanding
    //in date format, if it would have been 01/13/2011, it would have helped
    if (dateTimePicker1.Value.Date == 
           DateTime.ParseExact(date[inc], "MM/dd/yyyy", 
               new System.Globalization.CultureInfo("en-US")).Date)
    

    Also you can do .Trim() on date[inc] it might help you.

    EDIT

    When you compare string things to look for

    • White Spaces at beginning and at end. Remove them if required using .Trim()
    • Case Sensitivity. Do string.Equals(string1, string2, StringComparison.InvariantCultureIgnoreCase)

    Hope this works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have result string date xml export from database like 2011-06-27T14:03:19.5300000+07:00. How to Convert
I have char date[] = 2011-04-01; How it convert to timestamp in C or
How can I parse this date using DateTime.ParseExact?: 07/21/2011 23:59:59 in C#? Thanks :)
I have the following string: HTTP/1.1 200 OK Date: Tue, 06 Dec 2011 11:53:22
Is it possible to get the first / last date of a week using
How do I get today's date in C# in mm/dd/yyyy format? I need to
Is there a way to get notification of date change in c#? I have
WPF Toolkit, How to apply date format in C# for datepicker control?
It appears that Directory.GetFiles() in C# modifies the Last access date of a file.
How do I set the date/time of the computer in C#?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.