Page 1 of 1

How to create a reportvariable "datetime (nullable)" by code

Posted: Fri Nov 09, 2007 11:46 am
by Fabio Pagano
I need to create a reportvariable "datetime (nullable)" by code.

I try this:

Code: Select all

Dim v As New Stimulsoft.Report.Dictionary.StiVariable
v.Name = "MyName"
v.Alias = v.Name
v.Type = CType(GetType(Date), Type)
v.ReadOnly = False
v.Category = rv.Category
report.Dictionary.Variables.Add(v)
Note this line:

"v.Type = CType(GetType(Date), Type)"

The resulting reportvariable type is "DateTime", not "DateTime (nullable)" so if i pass a value of nothing the date is converted in today's date, if a pass a "date" variable (not assigned to any value) is converted in "01/01/0001". If i manually change the reportvariable type in "Datetime (nullable)" the field is left blank (that was i want).

So, how can i create by code a "DateTime (nullable)" reportvariable?

Or, alternatively, how can i print an empty field when i pass a value of "Nothing" to a "datetime" report variable?

Thanks.

How to create a reportvariable "datetime (nullable)" by code

Posted: Fri Nov 09, 2007 1:36 pm
by Brendan
Try using this line:

Code: Select all

v.Type = CType(GetType(Nullable(Of Date)), Type)
Regards,
Brendan