PC Review


Reply
Thread Tools Rate Thread

Dates in excell

 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      3rd Oct 2006
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 With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      3rd Oct 2006
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" <(E-Mail Removed)> wrote in message
news:0225AA4D-743F-478A-B0DD-(E-Mail Removed)...
> 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 With Quote
 
Norman Jones
Guest
Posts: n/a
 
      3rd Oct 2006
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" <(E-Mail Removed)> wrote in message
news:0225AA4D-743F-478A-B0DD-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
sum by dates-Excell 2003 Zirt Microsoft Excel Misc 1 24th Jul 2009 08:35 PM
My chart in Excell will only let me use 5 dates. ? WillB Microsoft Excel Charting 1 2nd Mar 2009 02:19 AM
DATES IN EXCELL =?Utf-8?B?REVOTklT?= Microsoft Excel Misc 8 29th Nov 2005 12:34 PM
Can excell notify me of due dates? =?Utf-8?B?RGVpb24wMDc=?= Microsoft Excel New Users 1 21st Oct 2005 09:35 PM
Excell & MailMerge dates Frustrated Microsoft Excel Misc 1 8th Jul 2004 02:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:54 AM.