简体   繁体   中英

I need to mask or suppress if null in crystal reports

Looking for Crystal Reports help! Crystal Reports 2013 SP5 V14.1.5.1501 Windows 7 pro environment.

I have table.date_field that is a date field formatted as such: xx/xx/xxxx. I'm putting it in a report that will be exported as a .csv so the field has to be 10 spaces which works fine if there is a date in table.date_field.

If table.date_field is null it returns ;; (.rpt has to be separated by semicolons).

I tried creating 2 formulas one I called @date_field_format and one I called @date_field_tweak.

@date_field_format has the following formula:

picture({table.date_field},'xx/xx/xxxx')  

@date_field_tweak has the following formula:

if isnull ({@date_field_format}) then
    space(10)
else
    left(trim(totext({@date_field_format}))+space(10),10) 

Using @date_field_tweak on the .rpt returns: ;2//21//201;

Any suggestions on how to get table.date_field on a report formatted like this xx/xx/xxxx with 10 spaces inserted in place of the date if table.date.field isnull?

Try this:

assuming your date format from database is 29/04/2015

if isnull ({Sheet1_.date}) then
    space(10)
else

Split(ToText(Cdate({Sheet1_.date})),"/")[1]+"/"+
Split(ToText(Cdate({Sheet1_.date})),"/")[2]+"/"+
Split(ToText(Cdate({Sheet1_.date})),"/")[3]

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