DateTimePicker - DateToStr - FormatSettings

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.

Thanks.

Bego.
begonzAsked:
Who is Participating?
 
Pierre CorneliusConnect With a Mentor Commented:
DateEntered:= FormatDateTime('yyyy-MM-dd', DateTimePicker1.Date)
0
 
saravananvgCommented:
Hello Sir,

  AS PierreC says, you can format it using FormatDateTime function

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

with regards,
padmaja.
0
 
Pierre CorneliusCommented:
@padmaja: why repeat what I have already said?
0
 
begonzAuthor Commented:
Thanks for that PierreC!  Easy points.  I almost had it just around the wrong way.  :o)
0
 
Pierre CorneliusCommented:
glad to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.