• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

How can I compare 2 DateTimePicker control (configre to display only time) for the time and not the date?

I'm using the following code but it's using the Date of the control and time during the comparison.  I only want to compare the time,   how can I do that?  Thanks.
 if ((toTime.Value.CompareTo(fromTime.Value)) < 0)
0
lapucca
Asked:
lapucca
1 Solution
 
Ravi SinghSenior Software EngineerCommented:
Hi, you can use the TimeOfDay property on the DateTime object:

if (toTime.Value.TimeOfDay < fromTime.Value.TimeOfDay)
{
             
}
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now