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 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

Ask A Question

Stats

  • Questions 215k
  • Answers 215k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer var scripts = document.getElementsByTagName("script"); give you a collection of all… May 12, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer Perhaps you can use the DATE_FORMAT() function, and grouping. Here's… May 12, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer You can group on a constant which might be useful… May 12, 2026 at 10:56 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.