p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VB.NET 2002/2003 Basics (http://p2p.wrox.com/forumdisplay.php?f=76)
-   -   Formatting Dates (http://p2p.wrox.com/showthread.php?t=10132)

Louisa March 5th, 2004 08:10 AM

Formatting Dates
 
I would like to format dates from a date picker as when i put them into access they are being transposed. I need to convert them from d/m/yy format to dd/mmm/yy format. I have tried using the VB6 method, but this seems not to work, can it be done if so how?

Thanks in advance

Louisa


jaucourt March 11th, 2004 05:37 AM

  Dim mydate As Date = CType(Me.DateTimePicker1.Text, Date)
  Dim myStringDate As String = mydate.Day.ToString & "/" & _
     MonthName(mydate.Month, True).ToString & "/" & _
     mydate.Year.ToString.Substring(2, 2)

myStringDate should be what you need, you can adjust the delimiter as needed.


planoie March 11th, 2004 10:30 AM

Or you could just do this:

myStringDate = String.Format("{0:dd/MMM/yy}", CType(Me.DateTimePicker1.Text, Date))

Louisa March 16th, 2004 05:52 AM

Thanks for you help

Louisa



All times are GMT -4. The time now is 07:42 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.