SSRS Default Date Parameter values (cookbook special)

Today I caught myself re-typing these so very common pieces of code…but there won’t be a next time!
CTRL+A…CTRL+C…TAB…CTRL+V…CTRL+S 😀

Current date:

=CDate(
CSTR(YEAR(NOW()))+"-"+
CSTR(MONTH(NOW()))+"-"+
CSTR(DAY(NOW()))
)

Previous week (-7 days):

=DateAdd(DateInterval.Day,-7,
CDate(
CSTR(YEAR(NOW()))+"-"+
CSTR(MONTH(NOW()))+"-"+
CSTR(DAY(NOW()))
)
)

First day of the current month:
=CDate(
CSTR(YEAR(NOW()))+"-"+
CSTR(MONTH(NOW()))+"-01"
)

First day of the previous month:
=DateAdd(DateInterval.Month,-1,
CDate(
CSTR(YEAR(NOW()))+"-"+
CSTR(MONTH(NOW()))+"-01"
)
)

Last day of the previous month:
=DateAdd(DateInterval.Day,-1,
CDate(
CSTR(YEAR(NOW()))+"-"+
CSTR(MONTH(NOW()))+"-01"
)
)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s