How to list last 7-day birthdays with Crystal Reports and c# winforms

Asked

Viewed 87 times

0

I’m developing a church management system, and I need to get all the faithful registered in the system, whose birthday is in the last seven days, counting the current date. I have created the following formulas:

CDate ({FIEIS.DataNasc_fl})>=CurrentDate-7

CDate ({FIEIS.DataNasc_fl})>=Last7Days

Both the first and the second formula did not work. If anyone has an idea how to do it, I really appreciate it!

@Motta! I tried it the way you posted it, it was wrong in the formula:

2 answers

0

(totext({Comando.NASC},"MMdd") >= totext(CurrentDate-7,"MMdd") and
 totext({Comando.NASC},"MMdd") <= totext(CurrentDate,"MMdd"))

Example I did here and it worked

  • ! I tried it the way you posted it, it didn’t work. It’s a mistake.

  • I’m also noticing the presence of extra parentheses.

  • wouldn’t be less? totext((Currentdate),"yyyyMM")

  • I’ve done it too, keep making the same mistake.

  • People! It can also be as follows: Put two datetimepicker (starting date and end date), to be able to search in a given period. For the CR take the dates as parameters. If anyone knows, also thank you. Although the priority is really the first way.

  • I changed my example, just change your field name

  • Guys! mexi na formula e ficou assim: totext({FIEIS.DataNasc_fl}) >= totext((CurrentDate-7),"dd-MM") and&#xA;totext({FIEIS.DataNasc_fl}) <= totext((CurrentDate),"dd-MM"). In Crystal Ports no error is found. But when I select that formula in Lection expert and value put true, the report appears blank.

  • @Motta. I tried again after the change, with Basic Syntax selects the first parenthesis and gives the following error: A statement is required here. With Crystal Syntax gives the following error: Too Many Arguments have been Given to this Function.

  • It has to be Mmdd because it keeps the date hierarchy, the solution I made worked for a DATE field applied in the Record Filter. and has to have the "totext" at both ends of the test to compare homogeneous things (dates converted into month and day string)

  • @Motta! I’m using Crystal Ports that comes bundled with VS2008. Does the Crystal Reports version have any infuence? 'Cause I’ve tried to do it the way it’s in the code that you’ve enhanced, and it keeps going wrong.

  • When I remove "Mmdd" from the formula, CR finds no error in it, but the report appears empty.

  • My field is Datetime. Does it matter?

  • "makes a question" would our "make a difference" ? (laughs) I believe not , should work because the totext will make the conversion. What is the data source ? A solution could be via query , using (for example) EXTRACT Month/day FROM ...

  • Here in Angola, we use both one and the other expression for the purpose (laughter). What exactly would this other solution look like?

Show 9 more comments

0

FINALLY GOT PEOPLE! I did it this way:

1) I created 4 SQL Expression Fields:

data1: {fn DAYOFYEAR("FIEIS"." Datanasc_fl")})

data2:({fn DAYOFYEAR({fn CURDATE()})}-7)

data3:{fn DAYOFYEAR("FIEIS"." Datanasc_fl")}

data4:{fn DAYOFYEAR({fn CURDATE()})}.

2) I created a formula "ult7days" that became like this:

{%data1}>={%data2} and {%data3}<={%data4}

And it worked! It’s catching the birthday kids of the last 7 days!!! Thank you very much to Brothers who gave me tips on this issue, especially @Motta. I hope to always count on you for the next questions I have.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.