Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default a quick way to determine the first and last biz date of the month

Hi all,

I don't remember the code now, but I came across a quick way to
determine the first and last biz date for a specified month using the
dateserial function.

I don't quite know how to how to get dateserial function to work, can
you share some thoughts/suggestions?

Thanks in advance,

Ben
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default a quick way to determine the first and last biz date of the month

Try

Function FirstOfMonth(MM As Long, YY As Long) As Date
FirstOfMonth = DateSerial(YY, MM, 1) + _
IIf(Weekday(DateSerial(YY, MM, 1)) = vbSaturday, 2, 0) + _
IIf(Weekday(DateSerial(YY, MM, 1)) = vbSunday, 1, 0)
End Function

Function EndOfMonth(MM As Long, YY As Long) As Date
EndOfMonth = DateSerial(YY, MM + 1, 0) - _
IIf(Weekday(DateSerial(YY, MM + 1, 0)) = vbSaturday, 1, 0) - _
IIf(Weekday(DateSerial(YY, MM + 1, 0)) = vbSunday, 2, 0)
End Function

where MM is the month and YY is the year.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Thu, 19 Feb 2009 13:43:31 -0500, Ben wrote:

Hi all,

I don't remember the code now, but I came across a quick way to
determine the first and last biz date for a specified month using the
dateserial function.

I don't quite know how to how to get dateserial function to work, can
you share some thoughts/suggestions?

Thanks in advance,

Ben

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default a quick way to determine the first and last biz date of the month

On Thu, 19 Feb 2009 13:43:31 -0500, Ben wrote:

Hi all,

I don't remember the code now, but I came across a quick way to
determine the first and last biz date for a specified month using the
dateserial function.

I don't quite know how to how to get dateserial function to work, can
you share some thoughts/suggestions?

Thanks in advance,

Ben



If you want to use worksheet function, try these

For the first Monday-Friday in the month in cell D1

=DATE(YEAR(D1),MONTH(D1),1+CHOOSE(WEEKDAY(DATE(YEA R(D1),MONTH(D1),1),2),0,0,0,0,0,2,1))

For the last Monday-Friday in the month in cell D1

=DATE(YEAR(D1),MONTH(D1)+1,0-CHOOSE(WEEKDAY(DATE(YEAR(D1),MONTH(D1)+1,0),2),0,0 ,0,0,0,1,2))

Hope this helps / Lars-Åke

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default a quick way to determine the first and last biz date of the month

Chip, Lars -

Thanks so much for the suggestions.

Ben



On 2/19/2009 1:43 PM, Ben wrote:
Hi all,

I don't remember the code now, but I came across a quick way to
determine the first and last biz date for a specified month using the
dateserial function.

I don't quite know how to how to get dateserial function to work, can
you share some thoughts/suggestions?

Thanks in advance,

Ben


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
Determine qty charged per month [email protected][_2_] Excel Programming 1 July 18th 07 07:39 PM
Need a way to determine the # of Saturdays in a month Chuck M Excel Worksheet Functions 4 July 5th 07 09:34 PM
Date arithmetic: adding 1 month to prior end of month date manxman Excel Worksheet Functions 2 July 14th 06 09:29 PM
Sort month/date/year data using month and date only SMW820 Excel Discussion (Misc queries) 6 June 22nd 06 05:14 PM
Determine begin month date from month end date. mikeburg[_59_] Excel Programming 3 January 13th 06 08:42 PM


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