DateTimePicker Control Set time to 00:00:00 instead of current time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pandehrushikesh
    New Member
    • Dec 2008
    • 5

    DateTimePicker Control Set time to 00:00:00 instead of current time

    Hi

    I have a form with the DateTimePicker control on it. When I select a date it gives a value like "date time" (Eg.: 5/12/2010 12:20:35 PM). But here the time returned is current time. What I need is for the date chosen from the picker automatically set the time to 00:00:00 instead of the time when the date was picked.

    Any suggestions?

    Thanks.
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    I would first make a new DateTime object with everything zeroed, then add in the date only, that the user picked

    Otherwise subtract the time from what the user picked using the .addhour(), addminute(), etc methods

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      You must be doing the same outsourced project as this guy:

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        It's a more common question than I would have thought, tlhintoq. I've actually created a user-defined function on our SQL Servers for trimming dates to different dateparts. We had a project where we needed to, in one view, group results by minute, and in another, group by day. So we used the function to get two different trimmed versions of the record date for different groupings.

        DateTime objects are great, but it would be nice if they had some methods like TrimToMonth/TrimToDay/TrimToMinute.

        Comment

        Working...