Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Dates in excell

The statement MyDate = (Mid$(fname, e, 8)) returns 8 characters from a
string in the format

JUL-2006

Excel is adding to that the day of the month so its returning the date
1/july/2006
I want it to default to the last day of the month and not the first, Is
there an easy way of doing it?

Thanks in advance.

Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Dates in excell

One solution, this extracts the date string, adds 1 month and then subtracts
1 day.
Error arises if the string is not a valid date!

MyDate = Dateadd("d",-1,Dateadd("m",1,Mid$(fname, e, 8)))

--
Cheers
Nigel



"Mike" wrote in message
...
The statement MyDate = (Mid$(fname, e, 8)) returns 8 characters from a
string in the format

JUL-2006

Excel is adding to that the day of the month so its returning the date
1/july/2006
I want it to default to the last day of the month and not the first, Is
there an easy way of doing it?

Thanks in advance.

Mike



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Dates in excell

Hi Mike,

Try something like:

'=============
Public Sub Tester()
Dim myDate As Date
Dim fname As String
fname = "JUL-2006"

myDate = DateValue(fname)
myDate = DateSerial(Year(myDate), Month(myDate) + 1, 0)
Debug.Print myDate
End Sub
'<<=============


---
Regards,
Norman



"Mike" wrote in message
...
The statement MyDate = (Mid$(fname, e, 8)) returns 8 characters from a
string in the format

JUL-2006

Excel is adding to that the day of the month so its returning the date
1/july/2006
I want it to default to the last day of the month and not the first, Is
there an easy way of doing it?

Thanks in advance.

Mike



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
sum by dates-Excell 2003 Zirt Excel Discussion (Misc queries) 2 July 24th 09 09:52 PM
My chart in Excell will only let me use 5 dates. ? WillB Charts and Charting in Excel 1 March 2nd 09 02:19 AM
Is there a way to automatically add sequential dates in excell? genectn New Users to Excel 1 April 3rd 07 04:24 PM
DATES IN EXCELL DENNIS Excel Discussion (Misc queries) 8 November 29th 05 12:34 PM
Can excell notify me of due dates? Deion007 New Users to Excel 1 October 21st 05 09:35 PM


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

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"