Click here to Skip to main content
15,881,769 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

Greetings Fellow Programmers.

How can i convert this 190118 int to Date > January 01, 2018 using RDLC Report Expressions.

Thanks.

What I have tried:

I've tried using this expression :
=Format(Fields!DCDATE.Value,"MM/dd/yyyy")

But i Get "#Error" from report viewer.
Posted
Updated 16-Jan-20 17:03pm

1 solution

Obviously the best way would be to use a date format for the field in the database. This way you could focus on formatting the date properly without any need to do conversions.

However, if the format in the database is currently DDMMYY you could perhaps use something like the following to convert the data to a date
CDate(Left({Fields!DCDATE.Value},2) + "/" + Mid({Fields!DCDATE.Value},3,2)  + "/" + "20" + Right({Fields!DCDATE.Value},2))

Remember to verify that the expressions correctly interprets days and months for example for first of February.
The to format the date you can try
ToText(previous formula, "MMM dd yyyy")
 
Share this answer
 
v2
Comments
Member 13198628 20-Jan-20 21:55pm    
ToText(previous formula, "MMM dd yyyy") In order to use this? I'll will use this previous formula > CDate(Left({Fields!DCDATE.Value},2) + "/" + Mid({Fields!DCDATE.Value},3,2) + "/" + "20" + Right({Fields!DCDATE.Value},2))

So that the output is this:
ToTEXT(CDate(Left({Fields!DCDATE.Value},2) + "/" + Mid({Fields!DCDATE.Value},3,2) + "/" + "20" + Right({Fields!DCDATE.Value},2)), "MM dd yyyy");
Wendelius 20-Jan-20 22:53pm    
Yes, you can embed the CDATE formula to the ToText formula

Note that there are three M characters (MMM) in the ToText if you want the name of the month instead of the number.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900