Solved

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

Posted on 2009-05-11
3
274 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

752 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