Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Get Last Day of Month

I'm trying to transform a number "200412" into the date of the last day of
that month. If A1 = "200412", I do below steps. Step 1 works fine, but in
Step 2, I can't figure out a formula to return "12/31/2004" or the last date
of month.

Any help would be appreciated.

Step 1:
In B1, I enter =RIGHT(A1,2) & "/" & (LEFT(A1,LEN(A1)-2))
which gives me "12/2004"

Step 2:
In C1, I'm trying to use the formula

EndOfMonth = DateSerial(Year(B1),Month(B1)+1,0)
to return "12/31/2004" but I get the error #NAME?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Get Last Day of Month

Assuming your year portion is always 4 digits

=DATE(INT(A1 / 100), MOD(A1, 100) + 1, 0)

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"scott" wrote in message
...
I'm trying to transform a number "200412" into the date of the last day of
that month. If A1 = "200412", I do below steps. Step 1 works fine, but in
Step 2, I can't figure out a formula to return "12/31/2004" or the last
date of month.

Any help would be appreciated.

Step 1:
In B1, I enter =RIGHT(A1,2) & "/" & (LEFT(A1,LEN(A1)-2))
which gives me "12/2004"

Step 2:
In C1, I'm trying to use the formula

EndOfMonth = DateSerial(Year(B1),Month(B1)+1,0)
to return "12/31/2004" but I get the error #NAME?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Get Last Day of Month

Change Step1 to
=DATEVALUE(RIGHT(A1,2) & "/" & (LEFT(A1,LEN(A1)-2)))

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to transform a number "200412" into the date of the last day of
that month. If A1 = "200412", I do below steps. Step 1 works fine, but in
Step 2, I can't figure out a formula to return "12/31/2004" or the last

date
of month.

Any help would be appreciated.

Step 1:
In B1, I enter =RIGHT(A1,2) & "/" & (LEFT(A1,LEN(A1)-2))
which gives me "12/2004"

Step 2:
In C1, I'm trying to use the formula

EndOfMonth = DateSerial(Year(B1),Month(B1)+1,0)
to return "12/31/2004" but I get the error #NAME?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Get Last Day of Month

And for step 3, use Date, not DateSerial
= DATE(YEAR(B1),MONTH(B1)+1,0)

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to transform a number "200412" into the date of the last day of
that month. If A1 = "200412", I do below steps. Step 1 works fine, but in
Step 2, I can't figure out a formula to return "12/31/2004" or the last

date
of month.

Any help would be appreciated.

Step 1:
In B1, I enter =RIGHT(A1,2) & "/" & (LEFT(A1,LEN(A1)-2))
which gives me "12/2004"

Step 2:
In C1, I'm trying to use the formula

EndOfMonth = DateSerial(Year(B1),Month(B1)+1,0)
to return "12/31/2004" but I get the error #NAME?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Get Last Day of Month

Thanks again. I think I'm almost through getting my spreadsheet formatted
for export to access db.


"Tom Ogilvy" wrote in message
...
And for step 3, use Date, not DateSerial
= DATE(YEAR(B1),MONTH(B1)+1,0)

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to transform a number "200412" into the date of the last day
of
that month. If A1 = "200412", I do below steps. Step 1 works fine, but in
Step 2, I can't figure out a formula to return "12/31/2004" or the last

date
of month.

Any help would be appreciated.

Step 1:
In B1, I enter =RIGHT(A1,2) & "/" & (LEFT(A1,LEN(A1)-2))
which gives me "12/2004"

Step 2:
In C1, I'm trying to use the formula

EndOfMonth = DateSerial(Year(B1),Month(B1)+1,0)
to return "12/31/2004" but I get the error #NAME?








  #6   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Get Last Day of Month

Scott,

The following copes with single digit months e.g.. 20042 or 200403 return
last date of February - 29/02/2004 (uk format date).

=Date(left(a1,4),mid(a1,5,2)+1,0)

"scott" wrote in message
...
Thanks again. I think I'm almost through getting my spreadsheet formatted
for export to access db.


"Tom Ogilvy" wrote in message
...
And for step 3, use Date, not DateSerial
= DATE(YEAR(B1),MONTH(B1)+1,0)

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to transform a number "200412" into the date of the last day
of
that month. If A1 = "200412", I do below steps. Step 1 works fine, but
in
Step 2, I can't figure out a formula to return "12/31/2004" or the last

date
of month.

Any help would be appreciated.

Step 1:
In B1, I enter =RIGHT(A1,2) & "/" & (LEFT(A1,LEN(A1)-2))
which gives me "12/2004"

Step 2:
In C1, I'm trying to use the formula

EndOfMonth = DateSerial(Year(B1),Month(B1)+1,0)
to return "12/31/2004" but I get the error #NAME?








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 month when date is in day/month/year format ccKennedy Excel Worksheet Functions 6 April 30th 09 03:32 AM
excel to make the days cary over month to month automaticly GARY New Users to Excel 1 April 19th 08 06:05 PM
Excel 2003 month to month data change grid Chad[_2_] Excel Discussion (Misc queries) 2 February 15th 08 01:36 AM
Converting Month Number to Month Text Abbreviation Bob Excel Worksheet Functions 10 May 12th 07 04:11 AM
transfer cell $ amount to other sheet month-to-month without overc Colin2u Excel Discussion (Misc queries) 1 July 28th 05 02:36 AM


All times are GMT +1. The time now is 07:36 PM.

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

About Us

"It's about Microsoft Excel"