[RESOLVED] Date Time Picker - Remove Time-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] Date Time Picker - Remove Time

  1. #1

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    805

    Resolved [RESOLVED] Date Time Picker - Remove Time

    I have a bunch of datetime pickers on my form.

    When I step through my program using F8 I notice that when the dtPicker is not changed by the user it writes a value to the database such as "07/25/2005".

    The problem I'm having is that when the user changes the date on the dtPicker it shows up in the program as "07/25/2005 9:40:45AM" which is not working because my database field is not a datetime.

    How can I trim the time off the end?

    Is there a property that does this or do I have to resort to something like a MID or LEFT function to get the values I want?

  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Date Time Picker - Remove Time

    You should be able to just format it.
    VB Code:
    1. DTPicker1.Value = Format(DTPicker1.Value, "mm/dd/yyyy")
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3
    PowerPoster
    Join Date
    May 2002
    Posts
    25,098

    Re: Date Time Picker - Remove Time

    In design mode, select the date picker. Press F4 to get the Properties window. Scroll all the way to the top of the Props window. There's one called "Custom" click the "..." button that's there (you may have to actualy select the property before it shows I think).

    A new dialog screen should pop up. There's a checkmark that controls if the date shoudl be displayed or not. Clear it. Set any other props you want. Click OK (or it may be close, I can't remember off the top of my head.) Yuo should be OK after that. If you are using the .Value property to get the date selected, it may still contain the time, just simply use the Format function to return only the date.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    805

    Re: [RESOLVED] Date Time Picker - Remove Time

    Thanks Hack...worked like a charm.

    That was such an easy fix I never thought of it!

  5. #5
    Lively Member
    Join Date
    Aug 2005
    Posts
    81

    Re: [RESOLVED] Date Time Picker - Remove Time

    Hi..............

    Date Time Picker has its Format property set it to

    1 - dtpShortDate

    it will give u value of datepicker in mm/dd/yyyy format

    I think it will solve your problem. If this is the solution or ur problem then Please let me know ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.