Display date in MM-dd-yyyy format SSRS report

谁说胖子不能爱 提交于 2019-12-08 15:58:34

问题


I have a SQL query: select ModifiedDate from Person.Person and this returns the date as 2/24/1998 12:00:00 AM

I'm trying to display this in MM/dd/yyyy format in SSRS report. I have used the expression =Format(Fields!ModifiedDate.Value,"MM/dd/yyyy")

But, still it's coming as 2/24/1998 12:00:00 AM

I want to display this as 2/24/1998.

How can I do this?


回答1:


I would recommend using the format codes:

Right click - properties on the cell, select format, click the ellipsis "...", and you can see the date formats from there. This will be converted into a date code when you OK the dialog. This is useful as it sets the date in the fomat the user wants to see it in.

To convert the data within SSRS and not the data source you could try using something like:

=Format(Cdate(Fields!SSS.Value),"dd/MM/yyyy")

Another sample for you without Cdate:

=Format(Fields!ModifiedDate.Value,"dd/MM/yyyy")



回答2:


There is a special function for formatting Dates in SSRS:

=FormatDateTime(Fields!ModifiedDate.Value, DateFormat.ShortDate)

It will return your date the way that you want it.




回答3:


As per your question,

To convert the date in SSRS you should try like this,

=FORMAT(Fields!ModifiedDate.Value,"MM-dd-yyyy")

Output would be,

12-06-2010 -- 12(Month)-06(Date)-2010(Year)



回答4:


If you want to get date in format of 'MM/DD/YYYY' use the following query andand you have to convert in varchar datatype.

select CONVERT(varchar(20),GETDATE(),101)



回答5:


Set the language of the entire Report to the language of the country the report is going to be run in.

For example for US it's en_US and for Australia it's en_AU.

Simple !




回答6:


I had this problem and i solve that by this code :

FormatDateTime('MM/dd/yyyy',ADOqueryname.fieldbyname('ModifiedDate').AsDateTime);



回答7:


I did two things to make it work:

1st, In Data set property Query - select CONVERT(varchar(20),ModifiedDate,101) from Person.Person

2nd, In expression - =Format(Fields!ModifiedDate.Value,"dd/MM/yyyy")

This worked for me.Thanks for the hints.




回答8:


You can use:

- FormatDateTime(Fields!ModifiedDate.Value, 2)

or:

- FormatDateTime(Fields!ModifiedDate.Value, DateFormat.ShortDate)

You will get the same result.



来源:https://stackoverflow.com/questions/23842365/display-date-in-mm-dd-yyyy-format-ssrs-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!