?
Solved

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

Posted on 2009-05-11
3
Medium Priority
?
282 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 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