Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS String to Date conversion (mmddyyyy)

I have a String field in a Dataset in (mmddyyyy) format.

I am trying to convert it into a Date field in SSRS.

I already tried using the below command but I am getting error.

CDate(Fields!LocalTXNDate.Value)

Can anyone please suggest.

like image 589
ASharma7 Avatar asked Mar 27 '26 08:03

ASharma7


1 Answers

While Larnu is correct, the way to do it is to correct the database, sometimes we lowly report makers have no say in making these changes - much less getting a DBA to do it in a reasonable amount of time.

If you can't change the data to be correct, the easiest way to convert and use the field as a date is to add a Calculated Field to the Dataset. Open the dataset properties, click on the Fields tab, Add a Calculated field. enter image description here

For the Expression, use string functions to parse the field into a generic date format and then CDATE to convert to a date type. Then use the new field for dates. You could also use this in your text box if it's not being reused but it's easier to manipulate the Calculated field.

=CDATE(
    RIGHT(Fields!LocalTXNDate.Value, 4) & "-" & 
    LEFT(Fields!LocalTXNDate.Value, 2) & "-" & 
    MID(Fields!LocalTXNDate.Value, 3, 2)
    )
like image 99
Hannover Fist Avatar answered Mar 29 '26 10:03

Hannover Fist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!