vishwa vishwa - 2 months ago 9x Question

How to use selection formula for crystal report for datetime column un

My problem is,How to set value to selection formula in crystal report for datetime column(im using sql server 2000).

selectionFromula="{tblMain.bday}='"& datetimepicker.value &"'"

when i use this, a error message is showing problem with selection formula.but when i use for another column,it work well like this,

selectionFormula="{}='"& txtid.text &"'"

but when it use for datetime type column,it doesn't work.can some one give me a working example for this.thanks


You are sending a string literal to the selection formula instead of a date. So, for example, if the datetimepicker.value is "1/1/2000", then Crystal would see


Either the string needs to be converted to a date value, or it needs to be flagged as a date literal using the pound sign (#).

One of these should be what Crystal sees.

//Using a conversion to a Crystal Date

//Using the Crystal Date literal

So your selection formula in VB would look like one of these

'Using a conversion to a Crystal Date
selectionFormula="{tblMain.bday}=CDate('"& datetimepicker.value &"')"

'Using the Crystal Date literal
selectionFormula="{tblMain.bday}=#"& datetimepicker.value &"#"