Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2013-01-10
2
4,029 Views
Last Modified: 2013-01-10
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
Comment
Question by:HemlockPrinters
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 400 total points
ID: 38764971
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
 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 100 total points
ID: 38764991
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question