Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DateTimePicker with Custom Format: DateTimePickerFormat.Short + DateTimePickerFormat.Time?

Posted on 2008-10-15
4
Medium Priority
?
1,914 Views
Last Modified: 2012-05-05
I have an application that is used worldwide. I use datetimepickers and the format needs to be <Short date> <Short Time>.
It doesn't appear that there is a way to do this. Using a custom format doesn't work because USA uses: MM/dd/yyy and many other countries use dd/MM/yyyy. I can't imagine that Microsoft wouldn't make a way to do this. What am I missing?
0
Comment
Question by:gcook17
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 22725031
The format strings can be combined to format the date and time. For example, to display the date and time as 06/15/2001 12:00 PM, this property should be set to "MM'/'dd'/'yyyy hh':'mm tt".

So add any other special characters in btw.

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"  'Another Formatter
0
 

Author Comment

by:gcook17
ID: 22725123
Thank you for your comment however I am aware of this: that you can combine the format strings. The problem with this is: With USA this format is fine: "MM'/'dd'/'yyyy hh':'mm tt" But with UK and many other countries the fomat must be "dd/MM/'yyyy hh':'mm tt. In VB6 yiu could concatenate "Short Date" & ' ' & "Short Time" to obtain the correct format regardless of the Regional Locale settings.
0
 
LVL 25

Accepted Solution

by:
apeter earned 2000 total points
ID: 22725480
1. Get the date from the date picker.
2. Create a date object from above value.
3. DateTime has two methods, ToShortDateString and ToShortTimeString(). Concatenate them.

Dim instance As DateTime
Dim returnValue As String
Dim instance As New DateTime(year, month, day)
returnValue = instance.ToShortDateString()

0
 

Author Closing Comment

by:gcook17
ID: 31506465
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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