CALCULAR IDADE CRYSTAL REPORTS 9.22

ALANTB 19/08/2014 09:34:24
#440580
Olá, estou usando vb6+access2003+crystal 9.22.Nunca tinha usado nenhuma versão do CR para relatórios, mas dessa vez resolvi arriscar. Parei em um campo do relatório onde deve ser exibida a IDADE do funcionário, mas não sei como inserir a fórmula para calcular.Nas conexões do CR eu consegui adicionar uma Consulta que criei no Access que puxa uma combinação de tabelas onde tem o campo dataNasc. No Macoratti em: http://www.macoratti.net/cr_vb_1.htm tinha esse exemplo, mas é feito em CR 4.6 e o meu é 9.22 tento copiar a fórmula mas só da erro. Alguém tem uma idéia de como fazer o ajuste ou tem outra solução???

Alan
ALANTB 19/08/2014 16:58:30
#440597
Pessoal,

Tô tentando inserir essa fórmula do Macoratti mas só dá erro , será que ta faltando algum comando ou tem coisa a mais. Quando vou salvar da erro e o CR seleciona do -1 em diante como se estivesse faltando argumentos. Ou será que a fórmula não está completa ai???

If month({Clientes.Nascimento}) = 2 and day({Clientes.Nascimento})=29
Then Date(Year(Today),3,1) –1 else

Else Date(year(Today),month({Clientes.Nascimento}), day({Clientes.Nascimento})
ALANTB 20/08/2014 15:55:06
#440619
Consegui com a fórmula do site abaixo. Sendo assim vou encerrar:
http://geekswithblogs.net/Compudicted/archive/2010/11/25/age-this-month-calculation-in-crystal-reports.aspx

Code:

// Age this month calculation
WhileReadingRecords;
dateTimeVar _1stOftheMonth := CurrentDate;
dateTimeVar LastOftheMonth := CurrentDate;

// Get the run date and make it the 1st day of the current month
_1stOftheMonth := Date(Year(_1stOftheMonth), Month(_1stOftheMonth), 01);

// Get the next month[ô]s 1 st day. Subtract 1 day to get the last day of the current month
LastOftheMonth := DateAdd( [Ô]d[Ô], -1, DateAdd([Ô]m[Ô], 1, _1stOftheMonth) );

// Proceed with the age calculation taking into consideration the leap year.VÊ SE é BISSEXTO
if (Month(LastOftheMonth) * 100) + Day(LastOftheMonth) >=
(Month(CDate({Employee_Master.BirthDate})) * 100) + Day(CDate({Employee_Master.BirthDate}))
then
Year (LastOftheMonth) - Year(CDate({Employee_Master.BirthDate}))
else
Year (LastOftheMonth) - Year(CDate({Employee_Master.BirthDate})) - 1;
Tópico encerrado , respostas não são mais permitidas