[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB - format datetime

Posted on 2010-09-09
8
Medium Priority
?
421 Views
Last Modified: 2013-11-27
How do I format this datetime:

      9/9/2010 12:00:00 AM

To:

      2010-09-09 12:00:00.000

0
Comment
Question by:Rick
8 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33639110
Dim dt As Date = "9/9/2010 12:00:00"
        Me.TextBox1.Text = dt.ToString("yyyy-MM-dd HH:mm.ss")
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33639120
sorry
Dim dt As Date = "9/9/2010 12:00:00"
        Me.TextBox1.Text = dt.ToString("yyyy-MM-dd HH:mm:ss.ms")
0
 
LVL 13

Author Comment

by:Rick
ID: 33639140
That gives me 2010-09-09 00:00:00.00
How do I show the milliseconds with 3 digits?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Accepted Solution

by:
vusov earned 2000 total points
ID: 33639147
Please try this Convert.ToDateTime("9/9/2010 12:00:00 AM").ToString("yyyy-MM-dd hh:mm:ss.fff")
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 33639151
On this page: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm  is a listing of DateTime.ToString() formats.

DateTime.ToString ( 'u' ) is close but more detailed versions are listed.

Note that 9/9/2010 12:00:00 AM will become 2010-09-09 00:00:00.000 in 24-hour time.
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33639161
Dim dt As Date = "9/9/2010 12:00:00"
        Me.TextBox1.Text = dt.ToString("yyyy-MM-dd HH:mm:ss.fff")
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 33639170
See: http://msdn.microsoft.com/en-us/library/8kb3ddd4(VS.80).aspx

You should be able to use "fff" for the milliseconds so "HH:mm:ss.fff" for the time portion.
0
 
LVL 13

Author Closing Comment

by:Rick
ID: 33639183
Thank you! That works.

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

829 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