My report prompts for a start and stop date. Based on the difference between those days, different dates are output.
So if a week or less, I report each day;
under a month, I report each week;
under a year, I report each month;
over a year, I report each year;
so here's the example:
if datediff('d',{?Start Date},{?End Date})<8
then totext(date({Command.CALL_INSTANT}), 'MM-dd-yy')
else if datediff('d',{?Start Date},{?End Date}) in [8 to 30]
then totext(dateadd("ww",datepart("ww",{Command.CALL_INSTANT})-1,date(year({Command.CALL_INSTANT}),1,1) - dayofweek(date(year({Command.CALL_INSTANT}),1,1)+0)), 'MM-dd-yy')
else if datediff('d',{?Start Date},{?End Date}) in [31 to 365]
then totext(date(year({Command.CALL_INSTANT}), month({Command.CALL_INSTANT}),1), 'MM-dd-yy')
else if datediff('d',{?Start Date},{?End Date}) > 365
then totext(date(year({Command.CALL_INSTANT}),1,1), 'MM-dd-yy')
if you wanted it to do it by month, you'd care about this portion:
else if datediff('d',{?Start Date},{?End Date}) in [31 to 365]
then totext(date(year({Command.CALL_INSTANT}), month({Command.CALL_INSTANT}),1), 'MM-dd-yy')
but I'm only using the code above because I want things to change based on how many days of data I'm pulling, if you're just using a date/time column, you can have it display by month by going into the chart expert and under columns if you have your date highlight it and choose group options and then under "The column will be printed", choose "for each month".
|