DateTimePicker - DateToStr  - FormatSettings

Posted on 2006-05-26
Last Modified: 2010-05-18
Can anyone tell me, how I can format a date that is in a DateTimePicker.

What the problem is, I have a DateTimePicker on a form and the input format is, yyyy/MM/dd.  That is fine.  When I try and use this value it puts it in a different format, dd/MM/yyyy.

I am doing the following:

DateEntered := DateToStr(DateTimePicker1.Date);

How can I force the date to be in the format yyyy/MM/dd into a variable to use, like it is on the screen???  I tried playing around with FormatSettings but just got lost.


Question by:begonz
    LVL 14

    Accepted Solution

    DateEntered:= FormatDateTime('yyyy-MM-dd', DateTimePicker1.Date)
    LVL 6

    Expert Comment

    Hello Sir,

      AS PierreC says, you can format it using FormatDateTime function

     DateEntered := FormatDateTime('yyyy/MM/dd',DateTimePicker1.Date)

    with regards,
    LVL 14

    Expert Comment

    by:Pierre Cornelius
    @padmaja: why repeat what I have already said?

    Author Comment

    Thanks for that PierreC!  Easy points.  I almost had it just around the wrong way.  :o)
    LVL 14

    Expert Comment

    by:Pierre Cornelius
    glad to help

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now