Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Text to date

Hi,

I am receiving date data in the following format: MM-YY, however, for some
reason there is no first zero. So June 2009 is just 609.

How can I convert it to a date, when I don't know if I'll have 3 digits
there (like the above example) or 4 digits (for example 1109 would be
November 2009).

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Text to date

You can use a formula: =TEXT(A1,"0000")

or in VBA:
dim strDate as string
strDate = Format(Range("A1"),"0000")

Sam


"jschping" wrote:

Hi,

I am receiving date data in the following format: MM-YY, however, for some
reason there is no first zero. So June 2009 is just 609.

How can I convert it to a date, when I don't know if I'll have 3 digits
there (like the above example) or 4 digits (for example 1109 would be
November 2009).

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Text to date

On Nov 4, 9:17*am, jschping
wrote:
Hi,

I am receiving date data in the following format: MM-YY, however, for some
reason there is no first zero. So June 2009 is just 609.

How can I convert it to a date, when I don't know if I'll have 3 digits
there (like the above example) or 4 digits (for example 1109 would be
November 2009).

Thanks!


=right(A1,2) will separate the year
=left(A1,Len(A1)-2) will pull out the month.

You can use the Date(year,month,day) function to create a date value.

HTH,

Tim Mills-Groninger
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Text to date

There are a couple of problems with your post. First, you are getting the
numbers in MYY format with **no** dash between them. Second, you are asking
how to make something like 609 into a date of June 2009; however, June 2009
is **not** a date because it does not have a day associated with it. So
there are two possible answers to your question... you just want the text
"June 2009" or you want a real date (for use in other calculations) in which
case you can specify a day (say, 1) and then format that real date to look
like June 2009. Which applies to you. Also, since you posted in a
programming newsgroup, I assume you are looking for VB code, so you need to
tell us where you are putting this "date"... in a cell or in variable.

--
Rick (MVP - Excel)


"jschping" wrote in message
...
Hi,

I am receiving date data in the following format: MM-YY, however, for some
reason there is no first zero. So June 2009 is just 609.

How can I convert it to a date, when I don't know if I'll have 3 digits
there (like the above example) or 4 digits (for example 1109 would be
November 2009).

Thanks!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Text to date

Thanks!

"Sam Wilson" wrote:

You can use a formula: =TEXT(A1,"0000")

or in VBA:
dim strDate as string
strDate = Format(Range("A1"),"0000")

Sam


"jschping" wrote:

Hi,

I am receiving date data in the following format: MM-YY, however, for some
reason there is no first zero. So June 2009 is just 609.

How can I convert it to a date, when I don't know if I'll have 3 digits
there (like the above example) or 4 digits (for example 1109 would be
November 2009).

Thanks!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Text to date

Well, I guess I completely missed what you were asking for. I thought when
you asked "How can I convert it to a date...?" that you wanted an actual
date (looking like month name followed by year) and not simply a guaranteed
4-digit number.

--
Rick (MVP - Excel)


"jschping" wrote in message
...
Thanks!

"Sam Wilson" wrote:

You can use a formula: =TEXT(A1,"0000")

or in VBA:
dim strDate as string
strDate = Format(Range("A1"),"0000")

Sam


"jschping" wrote:

Hi,

I am receiving date data in the following format: MM-YY, however, for
some
reason there is no first zero. So June 2009 is just 609.

How can I convert it to a date, when I don't know if I'll have 3 digits
there (like the above example) or 4 digits (for example 1109 would be
November 2009).

Thanks!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date format to Text Date for use in Mail Merge Erinayn Excel Discussion (Misc queries) 3 April 22nd 10 06:04 AM
Formula concatenating date & text converts date to number Wekiva Excel Programming 2 April 7th 09 08:28 PM
how do i convert text to date (mm/yy text to mm/dd/yyyy date)? lindsey Excel Discussion (Misc queries) 1 July 27th 07 10:05 PM
Concatenating a Text and a Date without losing orginal Date Format Hi_no_Tori Excel Discussion (Misc queries) 5 September 17th 06 06:35 PM
Change text to date and check against date in cell RW Excel Programming 3 February 2nd 06 03:29 PM


All times are GMT +1. The time now is 11:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"