473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Last day of the month

What's the best way in vba code to get the last day of the month for a given
date, i.e.
12/01/2004 gives 12/31/2004
12/14/2004 gives 12/31/2004
12/31/2004 gives 12/31/2004
?

Robert
Nov 13 '05 #1
6 35873
"Robert" <pr**********@yahoo.com> wrote in message
news:3w*****************@fe07.lga...
What's the best way in vba code to get the last day of the month for a given date, i.e.
12/01/2004 gives 12/31/2004
12/14/2004 gives 12/31/2004
12/31/2004 gives 12/31/2004


LastDayOfMonth: DateSerial(Year(DateField), Month(DateField) + 1, 0)

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
Robert wrote:
What's the best way in vba code to get the last day of the month for a given
date, i.e.
12/01/2004 gives 12/31/2004
12/14/2004 gives 12/31/2004
12/31/2004 gives 12/31/2004


Best, best...

Function monthEnd(dIn as date)as date
monthend=dateserial(year(din),month(din)+1,0)
end function

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #3
Thank you. This is helpful.
"Rick Brandt" <ri*********@hotmail.com> wrote in message
news:32*************@individual.net...
"Robert" <pr**********@yahoo.com> wrote in message
news:3w*****************@fe07.lga...
What's the best way in vba code to get the last day of the month for a

given
date, i.e.
12/01/2004 gives 12/31/2004
12/14/2004 gives 12/31/2004
12/31/2004 gives 12/31/2004


LastDayOfMonth: DateSerial(Year(DateField), Month(DateField) + 1, 0)

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #4
Thank you. dateserial is the best way.
"Bas Cost Budde" <b.*********@heuvelqop.nl> wrote in message
news:cp**********@news2.solcon.nl...
Robert wrote:
What's the best way in vba code to get the last day of the month for a
given date, i.e.
12/01/2004 gives 12/31/2004
12/14/2004 gives 12/31/2004
12/31/2004 gives 12/31/2004


Best, best...

Function monthEnd(dIn as date)as date
monthend=dateserial(year(din),month(din)+1,0)
end function

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Nov 13 '05 #5
Thank you.
"Rick Brandt" <ri*********@hotmail.com> wrote in message
news:32*************@individual.net...
"Robert" <pr**********@yahoo.com> wrote in message
news:3w*****************@fe07.lga...
What's the best way in vba code to get the last day of the month for a

given
date, i.e.
12/01/2004 gives 12/31/2004
12/14/2004 gives 12/31/2004
12/31/2004 gives 12/31/2004


LastDayOfMonth: DateSerial(Year(DateField), Month(DateField) + 1, 0)

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #6
Thank you.
"Bas Cost Budde" <b.*********@heuvelqop.nl> wrote in message
news:cp**********@news2.solcon.nl...
Robert wrote:
What's the best way in vba code to get the last day of the month for a
given date, i.e.
12/01/2004 gives 12/31/2004
12/14/2004 gives 12/31/2004
12/31/2004 gives 12/31/2004


Best, best...

Function monthEnd(dIn as date)as date
monthend=dateserial(year(din),month(din)+1,0)
end function

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SimonC | last post by:
I would like to return data from the last 2 weeks of each given month in Javascript, but in 2 formats. So, the penultimate week (Monday to Sunday) and the last week (Monday to ??) I'm not...
3
by: Gol Yass | last post by:
Dear Newsgroup, Is there a function in Access XP to take a date or month , and return the last day in that month? Ex: the last day in september is 30 or the last day in May is 31 . Thank...
3
by: Melissa | last post by:
I have this table: TblProjectYear ProjectYearID ProjectYearStartDate ProjectYearEndDate The Project Year will always span across December 31; for example 9/1/04 to 6/30/05. How do I build a...
7
by: MLH | last post by:
Public Function GetLastDayOfMonth(ByVal dtDay As Date) As Date '************************************************************************** ' Accepts a date. Determines month & year of the date....
5
by: hunt4grouse | last post by:
I'm looking for C code that will give me the last day of the month. Input - any day that I pass in as a variable.... input = 20050201 Output - calculate and format with slashes.... output =...
2
by: Sasidhar Parvatham | last post by:
Hello All, Is there a way I can get dates for first and last fridays of a month? Any suggestion would be helpful. Thanks.
4
by: laredotornado | last post by:
Hi, Using PHP 4, if I have a date, what is a function I could use to give me a date that represents the first day of that month? For example, if my date were "3/19/2006 8:00", I would want my...
3
by: ats | last post by:
Does anybody have any sample code for calculating the date for teh last Friday in each month. TIA -- ats@jbex When an old lady got hit by a truck I saw the wicked gleam in your eyes
11
by: Harlin Seritt | last post by:
Is there a module that can pull str values for say the last 3 months? Something like: print lastMonths(3) Thanks
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.