简体   繁体   中英

How to add Date in crystal Report c#

in my app I am showing a date in my crystal report and I have a column which is the number of months but it is a text in my database.
So, I create a formula field where I do the addition of the date and the month in order to get the new value of the date but I got an error telling me that the field is not numerical.
Here is my code to add the date

CDate(DateAdd ("M",ToNumber({TableName.interval}) ,{TableName.date} ))

TableName.interval is of type text and TableName.date is of type Date in my database.

You could try the DateValue function:

DateValue({myTable.strDate})

otherwise, parse it:

Date({myTable.strDate}[1 to 4], {myTable.strDate}[5 to 6], {myTable.strDate}[7 to 8])

Try to remove the CDate function I guess it will also work. Your final fomrula must look like:

DateAdd ("m",ToNumber({TableName.interval}),{TableName.date} )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM