Crystal Reports: using date from the datatime field as a parameter - crystal-reports

I am working on a report that I need to add a date range parameter. The field that I need to use in the datetime field, and I need to use the date portion from the field. I tried using the following, but the report returns no result.
cast(StartDateTime as date) between {?StartDate} and {?EndDate}
For the time being, I am using the Select Expert to sort the date range, but I have to manually enter the date in 'yyyy-mm-dd' format. Is there a way to set up the parameter, so that I can use the calendar to choose the dates?

I recommend to use one parameter field and set it to range and date instead of two.
With this you can use easily this formula:
{StartDateTime} = {?Parameter}
If you set the Parameter to Date instead of DateTime it will automatically check with the start of the day for the first range and the end of the day for the last range.

Related

SSRS - How to use a parameter that will determine if the other date parameter will be used to filter by delivery date or posting date

I am creating an SSRS report the will be filtered by a date parameter. However, i want to have an option for that Date parameter will be used to filter by Posting Date or Delivery Date
A parameter for the DATE_TYPE needs to be created with the Posting or Delivery as the available values.
If you want to do the filter in SQL, you would add something like:
WHERE 1 = 1
AND <CURRENT CRITERIA>
AND (POSTING_DATE = #DATE OR #DATE_TYPE <> 'Posting') --the parenthesis are VERY important here
AND (DELIVERY_DATE = #DATE OR #DATE_TYPE <> 'Delivery')
If the Date Type Parameter = Posting, the Posting Date must be the #DATE parameter. If it's not Posting then the second part of the OR will be True. Then it does a similar check on the Delivery Date field.
It's a little more complicated in the FILTER tab of SSRS's tables, charts or datasets.
In the Filter tab, add a new filter. Choose the Posting Date field as the Expression, date as the type and = as the operator. For the Value, press the Function button [Fx] to open the expression window. Your expression would be something like
=IIF(Parameters!DATE_TYPE.Value = "Posting", Parameters!DATE.Value, Fields!POSTING_DATE.Value)
The do the same for the Delivery date field.
This will compare the Posting date field to the date parameter if the DATE_TYPE is Posting. Otherwise it will compare the Posting date field to the Posting date field which will always be true when DATE_TYPE is NOT Posting.

How to add 13min's time in Time Field(not date time field) Crystal reports

I tried using Dateadd('n',13,{fieldname}).
but it throws an error not a valid date time field cause it is time field.
is there any way to convert it to datetime and add the value and revert it into time field?
Thanks.
Try this formula:
DateAdd('n',13,DateTime(CurrentDate, {fieldname}))
The DateTime(date, time) function will create a DateTime value that works in the DateAdd() function. This will only work if the {fieldname} is a Time data type though.
If {fieldname} is a string, you will need to convert it to a Time data type first using the Time(time) function.
The formula I suggested above will append your time value to today's date. You will then need to format the DateTime value it returns to only display the time value. This can be done by right clicking the field in your crystal report and clicking Format Field and setting the Style on the Date and Time tab.

The group options for a date, time or date-time condition field must be a date group

I'm using VS2017 and trying to convert my reports from Delphi to Asp.Net, but the problem with some until this point that My users can change their sort from the GUI and I need to dynamically adjust the sort in code to match their selection.
To do this I use the following code:
ReportDocument.DataDefinition.Groups[i].ConditionField = ReportDocument.Database.Tables[CrystalReportDatasource].Fields[cField];
However if cField is aDateField and the original is a StringField group I receive the following exception:
The group options for a date, time or date-time condition field must be a date
group options object crystal reports" when I try and excute the above
statement.
Any idea how to fix that?
When you group on a date, Crystal needs to know what type of date grouping you wish to apply (e.g. Every Day, week, or Month...).
You need to take care of that aspect in code or simply create a String formula to convert the date column to a string and Group on that formula instead of on the raw date column.

How to add a integer field to date field in maximo?

I need to add a integer field to the date field then output value should be in date format.
For Eg: frequency is integer field and certdate is date field i wrote a Set Value action in which I need to set the summation of both values to the Nextdate field(Date) and i am using db2.
If having a Value of :certdate + :frequency and a Parameter/Attribute of NEXTDATE isn't working for you, you'll need to revert to an automation script or Java class that uses the Date and Calendar classes to do what you want.

Convert yyyymmdd to date for record selection

I'm a Crystal newbie with limited experience at SQL commands.
Here's my problem.
My database stores dates in the yyyymmdd numeric format. I created a Date Range parameter field to allow the user to select a date range. When I try to add the {?Date Range} to the record selection I get an error message that says "A number range is required here", apparently because my {?Date Range} field is looking for a date and not a number. I believe what I have to do is convert my dates to a date format, but I don't know how to do that.
Could someone please tell me how to make this work?
Much appreciation, thanks
I don't have Crystal around to check the syntax , but generally you need to convert the daterange to numeric values and use theese values in your record selection formula
the TO value will be
tonumber(totext(Maximum({?ParameterDateRange}),'yyyyMMdd'))
the FROM value will be
tonumber(totext(Minimum ({?ParameterDateRange}),'yyyyMMdd'))
so the formula might be something like
{YourField} IN tonumber(totext(Minimum ({?DateRange}),'yyyyMMdd')) TO tonumber(totext(Maximum({?DateRange}),'yyyyMMdd'))
You can also use < and > instead of between
you can use CDate fucntion to convert numeric to Date.
CDate(ToNumber(Mid(ToText(20141231),1,4)),ToNumber(Mid(ToText(20141231),5,2)),ToNumber(Mid(ToText(20141231),7,2)))
Check the link for documentation
http://www-01.ibm.com/support/knowledgecenter/SS4JCV_7.5.5/com.businessobjects.integration.eclipse.designer.doc/html/topic728.html
Try:
{table.date} IN ToText(Minimum({?DateRange}),"yyyymmdd") TO ToText(Maximum({?DateRange}),"yyyymmdd")