GET FIRST AND LAST DAY BASED A DATE

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

GET FIRST AND LAST DAY BASED A DATE

Post by sal21 »

I have this var mydate 03/08/2014 (as date dimnensioed) i need based this date, to get the first and last day of this month?
In my case august/2014

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: GET FIRST AND LAST DAY BASED A DATE

Post by HansV »

First day of month: DateSerial(Year(MyDate), Month(MyDate), 1)
Last day of month: DateSerial(Year(MyDate), Month(MyDate) + 1, 0)
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: GET FIRST AND LAST DAY BASED A DATE

Post by sal21 »

HansV wrote:First day of month: DateSerial(Year(MyDate), Month(MyDate), 1)
Last day of month: DateSerial(Year(MyDate), Month(MyDate) + 1, 0)

perfect! :thankyou:

But this code consider the particular month "febrary"? i think yes :grin:

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: GET FIRST AND LAST DAY BASED A DATE

Post by Rudi »

Yep...even leap years will result in day 29. :smile:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.