Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cdatetime function for Year and Month

Status
Not open for further replies.

kuberacupidagra

Programmer
Oct 21, 2005
36
US
Hello All,

1) I am using the following CDateTime function to get data for T_AMNT field. It gives correct values for period 1/1/2005 to 12/31/2005

@TotalYearlyAmount
if {TTFGLD106530.T_DATE} >= CDateTime(2005,01,01,00,00,00) and {TTFGLD106530.T_DATE} <=CDateTime(2005,12,31,00,00,00)
then {TTFGLD106530.T_AMNT} else 0

2) Now I am trying to get the month data for November and December and the values returned for T_AMNT are 0. I have checked in the tables and there are many values for Nov and Dec.

@Nov_Month
if {TTFGLD106530.T_DATE} >= CDateTime(2005,11,01,00,00,00) and {TTFGLD106530.T_DATE} <=CDateTime(2005,11,30,00,00,00)
then {TTFGLD106530.T_AMNT} else 0


1) I also tried using the following and T_AMNT is still 0

@Nov_Month
if {TTFGLD106530.T_DATE} >= CDateTime(2005,11,01,00,00,00) and {TTFGLD106530.T_DATE} <=CDateTime(2005,11,30,00,00,00)
then {@TotalYearlyAmount} else 0

What could I be doing wrong?

Thanks,
AA



 
Where are you placing these formulas?

btw, you can simplify with:

if {TTFGLD106530.T_DATE} >= CDate(2005,11,01) and {TTFGLD106530.T_DATE} <=CDate(2005,11,30) then {TTFGLD106530.T_AMNT}
else
0

You also might use a Running Total, and in the evaluate-use a formula place the date criteria if you want summaries.

-k
 
Thanks synapsevampire,

I have placed the formula at Group Header, Group Foooter and also at the Details level. It always give 0 for the @Nov_Month.

I found that when I browse the field T_AMNT it has values which are not from the table. I removed the table with Database Expert and put it back. Now when I browse I still get values very different than what it is in the field in the real table.

It seems this is the reason it is getting 0 for the formula.

Any other ideas, please.

Thanks,

AA
 
Crystal doesn't create values, so there's something else going on, such as something in the Report->Selkection Formulas->Record, or using the wrong database, or your database connectivity isn't supported, or...

I should have already beaten you up about not posting basic technical information, I generally do:

Crystal version
Dtaabase/connectivity used
Example data
Expected output

The reason you aren't getting the output you want has nothing to do with the formulas, it's because it isn't being returned to the report from the database.

-k
 
Thanks Synapsevampire,

Have been trying to resolve the problem.

Definetely, the database is not returning the data I want. I tried changing the datasource location to the same table in another location. I get the error: Failed to Open a Rowset.

I tried creating a new report just for checking. I added the same table and gives the same error: Failed to open a dataset.

The Crystal Reports Version is 10
I am using SAS datasets.

What could be wrong?

Thanks,

AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top