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

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.

Related

Grafana, how to transform time column from timestamp to date

I am trying to use transformation "Convert field type" to strip time from timestamp,
but it seems not to work as I expect. Any idea how to get rid of time?
I need only date in order to group by day
If you just want to have a single line per day, you can use GROUP BY time(1d) in your query.
To hide the time part inside of the label, define an Override:

change date format in SSRS report dynamically

I am trying in D365 to create a dynamic date format, that is based on the preferences of the user. There is a field "Date, time, and number format" and based on the value of this field, the date format has to be changed. The field on the SSRS report is for some other purposes string, created by some values and one date field, so I would like to ask, if there is any function, that would in a code change the date format based on the user's preferences.
Many thanks for any advice

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

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.

How to convert a specific text string to today's date in Power BI

I have a table with a column called that contains text. Most of the values are years. However, some have the value "present" to represent groups that are still currently active. I want to convert those values to today's year, and convert the column type to date (specifically year type). I want to avoid creating a new column if possible.
Please see below for the DAX language that worked.
= Table.ReplaceValue(#"Extracted Year2",null,DateTime.LocalNow() ,Replacer.ReplaceValue,{"Disbanded"})

Crystal Reports default value for parameter

I'm attempting to make the parameters for a Crystal Report more user-friendly for a client, who has requested that they be able to have the default values for a Start and End date parameter be the first and last day of the previous month.
I know how to use either a formula in CR or a stored procedure to produce these values, but I want to know if a variable can be used in the 'Default Value' setting for a parameter, or if it only allows for static entries. Does anyone know? Right now the user can set the date parameters to null and the stored procedure generates the data for the previous month on its own, but I thought it'd be nice if the date parameters actually displayed the dates that were being used as defaults. Thanks in advance!
You can do it, Try below process:
Create a parameter ?date with String datatype and take static and write two default strings as below:
First day of previous month
Last day of Previous month
Now go to record selection formula and write below code:
if ({?date}="First day of previous month") then
table.date=DateSerial(year(currentdate),Month(Currentdate)-1,1)
else if ({?date}="Last day of previous month")
then
table.date=Cdate(DateAdd("d",-1,DateSerial(year(currentdate),Month(Currentdate),1)))