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

  • SEARCH
  • Home
  • 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 373767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:20:24+00:00 2026-05-12T14:20:24+00:00

I’m looking for a way to use two DateTimePicker controls to select a range

  • 0

I’m looking for a way to use two DateTimePicker controls to select a range of hours and minutes within one day. That is, to basically select a ‘starting time’ and ‘ending time’.

I started with two DateTimePicker controls with the custom format of h:mm tt. I tried adding (on ValueChanged), a check that made the selected ‘starting time’ will become the ‘ending times’ minimum and vice versa, the ‘ending time’ becoming the ‘starting times’ maximum (sorry its hard to explain, but thanks for your patience!)

However, that approach didn’t seem to work — I was still able to select 11.00 AM on the ‘ending time’ and 1.00 PM on the ‘starting time’. I have a feeling that the current day of the timestamp has something to do with it (e.g. the starting time is of the previous day, and therefore is less).

I thought about changing to a combo box of preset half hour intervals throughout the day; however the minutes need to be more flexible than that…

Any thoughts?

UPDATE:
Dan’s comment below answered this problem… This is the code I ended up with for reference;

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged

    DateTimePicker2.MinDate = Date.Today + DateTimePicker1.Value.TimeOfDay

End Sub

Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged

    DateTimePicker1.MaxDate = Date.Today + DateTimePicker2.Value.TimeOfDay

End Sub

DateTimePIcker1 being the lower bound, DateTImePIcker2 being the upper bound, both using “h:mm tt” as a custom datetime format.

Storing these preferences will now just use the Value.TimeOfDay (and be stored as a timespan), then on retrieval the following load process occurs;

DateTimePicker1.Value = Date.Today + StoredTimeLowerBound
DateTimePicker2.Value = Date.Today + StoredTimeUpperBound

This will automatically call the ValueChanged events handled above and restore the selected values.

Dan, thanks for your help 🙂

  • 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-12T14:20:24+00:00Added an answer on May 12, 2026 at 2:20 pm

    This will make sure both of your times are from today:

    Dim startTime As Date = Date.Today + DateTimePicker1.Value.TimeOfDay
    Dim endTime As Date = Date.Today + DateTimePicker2.Value.TimeOfDay
    

    Then you can write If endTime < startTime Then endTime = startTime or whatever you want.

    Lastly, just put your modified Date values back into the DateTimePicker controls:

    DateTimePicker1.Value = startTime
    DateTimePicker2.Value = endTime
    

    EDIT: For a range of hours you want a TimeSpan object, which is automatically the result of addition/subtraction of DateTime objects:

    Dim range As TimeSpan = endTime - startTime
    Dim numHours As Double = range.TotalHours
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.