Solved

How to Convert MON DD HH:MM:SS YYYY Format in VB?

Posted on 2009-05-11
3
277 Views
Last Modified: 2012-05-06
I have a date/time value I'm reading from a database that returns the date/time in this format:
May 01 16:17:32 2009    ... I would like to convert this to a better format, such as this:
05/01 16:17:32

I don't see an easy way to do that in VB ... can someone help?  Thanks.
0
Comment
Question by:UPRRDevelopers
[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
3 Comments
 
LVL 7

Accepted Solution

by:
FER_G earned 500 total points
ID: 24354265
UPRRDevelopers; I think that could be many ways to get that you want.
I only recommend you this one.

'Apply a Split function to the date
strDate="May 01 16:17:32 2009"
aDate=split(strDate," ")

doing this, you'll get all the data in a separate element of the array...
i.e.:
?aDate(0) --> month
?aDate(1) --> day
?aDate(2) --> hour
?aDate(3) --> year

so whit this, you can format and generate the date in the format that you need


FerG
Saludos.
--
Ing. Fernando D. Giletta
San Francisco. Córdoba. Argentina.
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 24354721
If the date is indeed stored as a date in the database, you can do
dim MyDate as string
MyDate = Format(rs.fields("DBDateField"), "mm/dd Hh:Nn:Ss")
0
 

Author Closing Comment

by:UPRRDevelopers
ID: 31580133
Perfect... thanks for the quick answer!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month4 days, 13 hours left to enroll

636 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