Tags: database, dates, defaults, following, microsoft, monthly, mysql, oracle, parameter, pls, report, server, somebody, sql

Report parameter - First day of last month/last day of month

On Database » Microsoft SQL Server

1,850 words with 1 Comments; publish: Sun, 01 Jun 2008 22:19:00 GMT; (250109.38, « »)

can somebody pls. help me with the following report parameter defaults?

for a monthly report I need two dates as parameter defaults:

The first day of the last month

and

the last day of last month

If I run a report on - let's say March 1st, I can get the last day of the

last month with

=Today.AddDays(-1)

and the first day of the last month with

=Today.AddMonths(-1)

However, I need these paramers to work every day. For example, I want to be

able to run the report on March 3rd or March 15th, and the report should also

have February 1st and February 28th as start and end dates.

How can I do this?

Thank you for helping,

Martin

All Comments

Leave a comment...

  • 1 Comments
    • Hi Martin,

      This will work everyday. start and end date of last month.

      start date - str(year(today)) + "/" + str(month(today)-1) + "/1"

      End Date - dateadd("d",-1, (str(year(today)) + "/" + str(month(today)) +

      "/1"))

      Now the date format ie dd/mm/yy or mm/dd/yy etc... I hope you can change it.

      Amarnath

      "Martin" wrote:

      > can somebody pls. help me with the following report parameter defaults?

      > for a monthly report I need two dates as parameter defaults:

      > The first day of the last month

      > and

      > the last day of last month

      > If I run a report on - let's say March 1st, I can get the last day of the

      > last month with

      > =Today.AddDays(-1)

      > and the first day of the last month with

      > =Today.AddMonths(-1)

      > However, I need these paramers to work every day. For example, I want to be

      > able to run the report on March 3rd or March 15th, and the report should also

      > have February 1st and February 28th as start and end dates.

      > How can I do this?

      > Thank you for helping,

      > Martin

      >

      #1; Sun, 01 Jun 2008 22:21:00 GMT