How to Change Date Format in .net RDLC Report?

元气小坏坏 提交于 2019-11-29 17:04:05

问题


I need to set my date column as 01-Jan-2013, what is the format to acheieve this in rdlc?

I have given

=CDate(Fields!IssuingDate.Value).ToString("dd-mmm-yyyy")

its not working correctly. Any one post me the format for 02-Jul-2013.


回答1:


Use this you will get your output

=CDate(Fields!IssuingDate.Value).ToString("dd-MMM-yyyy")



回答2:


Possibility 1:

I think the correct format string is "dd-MMM-yyyy" (uppercase M, see MSDN)

And I would use Format(Fields!IssuingDate.Value,"dd-MMM-yyyy")instead of ToString()

Possibility 2:

Just use Fields!IssuingDate.Value as Expression of your TextBox and set the Format property of the TextBox to dd-MMM-yyyy




回答3:


Date formats can also be changed by right clicking the field in the RDLC report (whose format we want to change) and:

  1. choose "Text box properties"
  2. then choose the option "Number"
  3. then choose one of the multiple "Date" options, or specify a Custom formatting option




回答4:


In the Expression property, set the following format and it will work fine:

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



回答5:


Do not use any formatting function like Format(). Instead right click on the text box and select Text Box Properties... And then select Number from left column and set your desire format like in Excel.

You can many other properties like Alignment, Fill and Action.




回答6:


CDate(Fields!IssuingDate.Value).ToString("dd-mmm-yyyy")

Change it as follows it will work definitely:

ToString should be toString and mmm should be MMM, so you'll have:

CDate(Fields!IssuingDate.Value).toString("dd-MMM-yyyy")



回答7:


This works, too (and doesn't fail when DateValue.Value is null):

=String.Format("{0:dd-MMM-yyyy}", Fields!DateValue.Value)



回答8:


You can edit your rdlc as XML and just use Now(), the same as DateTime.Now, and Format.

<Value>="Date: " &amp; Format(Now(), "dd/MM/yyyy HH:mm")</Value>

Result in file "Date: 22/08/2019 10:20"




回答9:


Check the datatype in XSD is System.DateTimeOffset, I couldn't get any formatting working without changing the type to System.DateTime .

Covert datetimeoffset to datetime from the select query:

SELECT 
A,
B,
CONVERT(datetime2, MyTable.DateTimeOffsetField, 1) AS DateTimeField
FROM MyTable

After changing the type to DateTime all the formatting started working

Eg: =Format(Fields!DateTimeField.Vaule, "dd-mmm-yyyy")



来源:https://stackoverflow.com/questions/17802399/how-to-change-date-format-in-net-rdlc-report

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