September 22, 2008 at 8:55 am
hi
in my report i have a date field i need to create two parameters to convert the date field to weeks and year for the user to select the week and a year.
i also created something like this {Command.CompleteByDate} = DatePart("yyyy",{?GetYear}) and
DatePart("ww",{?GetWeekNo})
i'm getting an error 'date-time is required'.
please help i'm not sure what i'm doing wrong
October 9, 2008 at 12:52 pm
I think that the first thing that you need to do is get your data into the correct format:
If you have a date variable, CONVERT or CAST it to DATETIME using T-SQL
Crystal looks at it in the reporting environment like this:
DATETIME(2003,11,11, 0, 0, 0)
yyyy, mm, dd, h, m, s
October 13, 2008 at 11:32 am
If the {?GetYear} and {?GetWeekNo} parameters are what they look like, either numbers or strings, then your formulas are incorrect. DatePart, both in SQL and in Crystal Reports, are expecting dates, not numbers.
If you want to treat the two parameters together as a date, you have to "merge" them into some sort of date. Of course, there are 7 dates for each combination (every given week + year), so you will have to decide which date always gets returned for any given combination. If you create a formula to return various results for different weeks/years you can see what is being entered into the formula, and how to proceed to create a date from them.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply