[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5245
  • Last Modified:

vba code to get first date and last day of previous month

For example, it's January now, I want to get first date of December  as "12/01/2012", last date is "12/31/2012"

Thanks.
0
HemlockPrinters
Asked:
HemlockPrinters
2 Solutions
 
zorvek (Kevin Jones)ConsultantCommented:
First day of previous month:

    Debug.Print DateSerial(Year(Now()), Month(Now) - 1, 1)

Last day of previous month:

    Debug.Print DateSerial(Year(Now()), Month(Now), 0)

Kevin
0
 
MacroShadowCommented:
Here you will find many useful date functions, for example:

    Business days between two dates.
    Business day + days = next business date
    Easter (Western)
    Age
    First Day of Quarter
    First Day of Week
    First Day of Month
    First Day of Previous Month
    First Day of Next Month
    Last Day of Quarter
    Last Day of Week
    Last Day of Month
    Last Day of Previous Month
    Last Day of Next Month
    First Weekday (sun, mon, etc) following specified date.
    Special DateDiff function that separates the answer into parts
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now