Showing posts with label month. Show all posts
Showing posts with label month. Show all posts

SSRS Reports get Month name from Month Index or from date

This is one of the small tips which I want to tell my readers. When you work with SSRS reports, you may come across with the requirement like, you know the index of the month, but you want to print month name from it. So, if that is the situation for you, this is the right post for you. :)
MonthName(monthindex) 
You may get it from t-SQL as I mentioned in my previous post here.
But in SSRS reports the way you  need to approach is like this.
  1. Take a textbox to report body.
  2. Write the below syntax into it [As you know, it is the expression].
=MonthName(7)

In any case, you need to get it by date then you still use this below function.
=MonthName(Month(Fields!datefield.Value))

Hope this helps and please let me know, if you face any problems. Read More...

How to know the number of days in a month in t-sql

Some times we can get requirement to know the number of days in a given month. For example, while calculating how many days remaining in a month or last day of month or any other scenarios.
Here is a small script that will give you the number of days for given month. Example purpose, i am retrieving month from the current date.

declare @numberOfDaysInMonth int;

set @numberOfDaysInMonth = DAY(DATEADD (m, 1, DATEADD (d, 1 - DAY(getdate()), getdate())) - 1);

Read More...

How to know month name from month index in t-sql

When I am working with reports, this is what every time I am looking for. Everyone gives date on the report as input, and I want display the month name on the report instead of month index [1-12]. So, how to do it?

please use the below script to get the name of the month by month index.
DateName(month, convert( datetime, '2007-' + cast(month(getdate()) as varchar(2)) + '-01', 120))

Here month(getdate()) returns the current month index from getdate() function. Hope this helps... Read More...
Related Posts with Thumbnails
GiF Pictures, Images and Photos