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

I'm trying to figure out how to convert same dates I have into a text
string. I.e., in cells F4 and F5 there are dates resulting from
manipulation of other dates. If the 2 dates are June 1, 2005 and Aug 1
2006, I want a text field that looks like:
06-12,05 - 01-08,06.
It lists the remaining months in the year and the months up to the
second date. If there's a full intervening year, it should list that
as 01-12,06 between the other two. Is this doable w/o code? If I need
to write a program, I will.
Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default dates to text

You need to concatenate two strings with an "&"

=text(F4,"mm-dd,yy")&" - "&text(F5,"mm-dd,yy")


"davegb" wrote:

I'm trying to figure out how to convert same dates I have into a text
string. I.e., in cells F4 and F5 there are dates resulting from
manipulation of other dates. If the 2 dates are June 1, 2005 and Aug 1
2006, I want a text field that looks like:
06-12,05 - 01-08,06.
It lists the remaining months in the year and the months up to the
second date. If there's a full intervening year, it should list that
as 01-12,06 between the other two. Is this doable w/o code? If I need
to write a program, I will.
Thanks for the help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default dates to text

On Thu, 19 Jun 2008 10:00:02 -0700, Joel wrote:

You need to concatenate two strings with an "&"

=text(F4,"mm-dd,yy")&" - "&text(F5,"mm-dd,yy")

Thanks for your reply, it helps. But it's not quite what I'm asking for.
I'm beginning to think I'll need some code to create the string.

"davegb" wrote:

I'm trying to figure out how to convert same dates I have into a text
string. I.e., in cells F4 and F5 there are dates resulting from
manipulation of other dates. If the 2 dates are June 1, 2005 and Aug 1
2006, I want a text field that looks like:
06-12,05 - 01-08,06.
It lists the remaining months in the year and the months up to the
second date. If there's a full intervening year, it should list that
as 01-12,06 between the other two. Is this doable w/o code? If I need
to write a program, I will.
Thanks for the help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default dates to text

Try this. it is the old formula for less the 2 years different from F4 to
F5. I added a third date if there is a full year between the dates.

=IF(YEAR(F5)-YEAR(F4)<2,TEXT(F4,"mm-dd,yy")&" -
"&TEXT(F5,"mm-dd,yy"),TEXT(F4,"mm-dd,yy")&" -
"&TEXT(F4,"mm-dd,")&RIGHT(YEAR(F4)+1,2)&" - "&TEXT(F5,"mm-dd,yy"))
"salgud" wrote:

On Thu, 19 Jun 2008 10:00:02 -0700, Joel wrote:

You need to concatenate two strings with an "&"

=text(F4,"mm-dd,yy")&" - "&text(F5,"mm-dd,yy")

Thanks for your reply, it helps. But it's not quite what I'm asking for.
I'm beginning to think I'll need some code to create the string.

"davegb" wrote:

I'm trying to figure out how to convert same dates I have into a text
string. I.e., in cells F4 and F5 there are dates resulting from
manipulation of other dates. If the 2 dates are June 1, 2005 and Aug 1
2006, I want a text field that looks like:
06-12,05 - 01-08,06.
It lists the remaining months in the year and the months up to the
second date. If there's a full intervening year, it should list that
as 01-12,06 between the other two. Is this doable w/o code? If I need
to write a program, I will.
Thanks for the help.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dates to text

I think this VB function will do what you want. Place it in a Module and you
can either call it from within your own subroutines and/or functions or
simply call it as a User Defined Function (UDF) from the worksheet itself.
Just pass in two dates (in any order) and it should return a text string
containing what you requested...

Function MakeDateRange(D1 As Date, D2 As Date) As String
Dim Y As Long
Dim StartDate As Date
Dim EndDate As Date
If D1 < D2 Then
StartDate = D1
EndDate = D2
Else
StartDate = D2
EndDate = D1
End If
If Year(StartDate) = Year(EndDate) Then
MakeDateRange = Format(StartDate, "mm") & "-" & _
Format(EndDate, "mm") & "," & Right(Year(EndDate), 2)
Else
MakeDateRange = Format(StartDate, "mm") & "-12," & _
Right(Year(StartDate), 2) & " - "
For Y = Year(StartDate) + 1 To Year(EndDate) - 1
MakeDateRange = MakeDateRange & "01-12," & Right(Y, 2) & " - "
Next
MakeDateRange = MakeDateRange & "01-" & Format(EndDate, "mm") & _
"," & Right(Year(EndDate), 2)
End If
End Function


Rick

"davegb" wrote in message
...
I'm trying to figure out how to convert same dates I have into a text
string. I.e., in cells F4 and F5 there are dates resulting from
manipulation of other dates. If the 2 dates are June 1, 2005 and Aug 1
2006, I want a text field that looks like:
06-12,05 - 01-08,06.
It lists the remaining months in the year and the months up to the
second date. If there's a full intervening year, it should list that
as 01-12,06 between the other two. Is this doable w/o code? If I need
to write a program, I will.
Thanks for the help.




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
Count Dates between Dates exclude Text Ken Excel Discussion (Misc queries) 3 April 8th 09 07:59 PM
How do I convert dates stored as dates to text? diamunds Excel Discussion (Misc queries) 5 September 7th 07 05:38 PM
Format text 'dates' to real dates Jacy Excel Worksheet Functions 4 July 24th 06 02:10 AM
Converting Text dates into dates EAB1977 Excel Programming 2 January 20th 06 04:20 PM
convert dates stored as text to dates lenko Excel Programming 2 December 5th 04 06:30 PM


All times are GMT +1. The time now is 09: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"