AllExperts > VB Script 
Search      
VB Script
Volunteer
Answers to thousands of questions
 Home · More VB Script Questions · Answer Library  · Encyclopedia ·
More VB Script Answers
Question Library

Ask a question about VB Script
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Subbu
Expertise
I can answer VB Script questions which are related to Visual Basic / VBA / QTP Scripts.

Experience
8 Years

Education/Credentials
Master of Computer Applications

Awards and Honors
Established Member from QA Forums and Brainbench certification

 
   

You are here:  Experts > Computing/Technology > Basic > VB Script > Extract DAte from a string

VB Script - Extract DAte from a string


Expert: Subbu - 5/18/2009

Question
QUESTION: HI I have a column which contains data in the format :
l3=12/3/2009
l3=23/4/2009
...
...

I need to extract the date part from it...
I do not want to trim the first 3 characters and get the date out of it,,because i need to process the date further..

Is there any function that can accomplish that..
Thanks


ANSWER: Ashish,

There are two steps to get your dates.

Col A           Col B
13=11/12/2008   39764 use =DATEVALUE(MID(A1,4,LEN(A1)-3)) to get 39764
13=11/3/2008   39755
13=11/2/2008   39754

Then select all date value cells, select Format Menu, Cells Option, select date format you want.


Another method is you can use VBA code to display date in date format directly.  If you want VBA code I need some time to write it.

Thanks.



---------- FOLLOW-UP ----------

QUESTION: Hi thanks but this does not gives me the solution . The reason is the in the text format l3=11/12/2008,
dd = 11, mm=12, yyyy=2008
once i covert it into Date format after applying the formula u have givern, it returnas 12 November 2008 but as per my requirement it should be 11 December 2008

Answer
Did you try with changing date format in custom?

Steps:
1. select the Datevalue cells
2. Goto Format menu and select cells option
3. Select Custom from Category and apply various date formats what ever you want and check it for your final result.

Let me know still you have any trouble.

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.