I have an expression in Crystal Reports which is not working:

1. {OEINH1.IHDOCD}  = ToText(CurrentDate - 1, 'yyyyMMdd')

This field IHDOCD is defined as number on IBM i.

 IHDOCD     PACKED       8  0       5        49        Both     WWDOCD    
   Field text  . . . . . . . . . . . . . . . :  DOCUMENT DATE             
   Referenced information                                                 
     Referenced file . . . . . . . . . . . . :  ISIXREF                   
       Library . . . . . . . . . . . . . . . :  STOBJR82A                 
     Referenced record format  . . . . . . . :  RISIXRF                   
     Referenced field  . . . . . . . . . . . :  WWDOCD                    
     Attributes changed  . . . . . . . . . . :  None                      


But CR gives this error message: 'A number is required here'

I am creating there a simple 'Record Selection" Perhaps there is a formula needed to code based on ibm I db2?

In SQL Server, the SQL Expression formula would be: 

replace(convert(varchar, "DATE_FIELD", 111), '/','')
有帮助吗?

解决方案

Without knowing Crystal Reports, it seems likely that the issue is the function you are using. If you are converting a value ToText then the amswer will be considered a character string, even if the contents happen to be numeric characters.

You are on the right rack with your T-SQL expression.

To get the numeric result that you can use in a record selection clause, try something like this:

    dec( replace(char(current_date - 1 day),'-','') ,8,0)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top