Issue
I have a formula in Crystal Reports that is written in Basic Syntax in order for it to be used with the HTML text interpretation. In one part of the code, I would like to add six months to Today's date. I know the DateAdd function can do this but I keep getting an error stating that a date is required. I know that the DateAdd function works without any problems in Crystal Syntax Mode, but I need to remain in Basic Syntax mode in order for the other code in the formula to work. What is the proper way to use DateAdd in Basic Syntax mode in Crystal Reports?
I tried using code similar to this:
dim sdate as date
sdate = DateAdd("m", 6, Today)
formula = sdate
When I try to save it, it returns an error and highlights the DateAdd function and the arguments ("DateAdd("m", 6, Today")
and says
"A date is required here."
Solution
The DateAdd
function returns a DateTime
, but sdate
is declared as Date
.
So there are two possibilities:
If the time part is required, declare
sdate
asDateTime
and useCurrentDateTime
instead ofToday
:Dim sdate As DateTime sdate = DateAdd("m", 6, CurrentDateTime) formula = sdate
If the time part is not required, convert the result of
DateAdd
toDate
:Dim sdate As Date sdate = CDate(DateAdd("m", 6, Today)) formula = sdate
Answered By - MatSnow Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.