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
Solved

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

Posted on 2008-10-15
4
1,855 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
  • 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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