Erro na conversar de char para datetime
Ola,
Exite uma tela de registro de adiantamento de salario e quando clico no botão ok aparece a seguinte mensagem:
The statement has bee terminated.
The conversion of char data type to a datetime data type result in a out of raze datetime value.
ESSE É O CÓDIGO E NA SETA QUE ESTOU INDICANDO É ONDE SURGE ESSA MENSAGEM.
pr006.texsql.sql.clear;
pr006.texsql.sql.add('insert into fpd011 (codemp, codfun, mesano, datven, totven, torven, tofven, totdes, tordes, tofdes, valliq, varliq, vafliq) values (' +
#39 + fpd005codemp.asstring + #39 + ', ' +
#39 + fpd005codfun.asstring + #39 + ', ' +
#39 + inttostr(wfolmes) + inttostr(wfolano) + #39 + ', ' +
->#39 + inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring + #39 + ', ' +
#39 + '0.00' + #39 + ',' +
#39 + '0.00' + #39 + ',' +
#39 + '0.00' + #39 + ', ' +
#39 + formatfloat('#######0.00',wvallan) + #39 + ',' +
#39 + formatfloat('#######0.00',wvallan) + #39 + ',' +
#39 + '0.00' + #39 + ', ' +
#39 + formatfloat('#######0.00',(wvallan * -1)) + #39 + ',' +
#39 + formatfloat('#######0.00',(wvallan * -1)) + #39 + ',' +
#39 + '0.00' + #39 + ')');
pr006.texsql.execute;
ESSAL LINHA TENTEI FAZER NESSAS cinco FORMAS: (obs: diapag é do tipo integer)
#39 + DATETIMETOSTR(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring) + #39 + ', ' +
#39 + STRTODATETIME(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring) + #39 + ', ' +
#39 + inttostr(wano) + '-' + inttostr(wmes) + '-' + inttostr(arq998diapag.value) + #39 + ', ' +
#39 + datetimetostr(inttostr(wano) + '-' + inttostr(wmes) + '-' + inttostr(arq998diapag.value)) + #39 + ', ' +
e até criei uma variavel do tipo tdatetime e nada.
alguem sabe me dizer como posso arrumar?
obrigado
"Deus Abençoe"
Exite uma tela de registro de adiantamento de salario e quando clico no botão ok aparece a seguinte mensagem:
The statement has bee terminated.
The conversion of char data type to a datetime data type result in a out of raze datetime value.
ESSE É O CÓDIGO E NA SETA QUE ESTOU INDICANDO É ONDE SURGE ESSA MENSAGEM.
pr006.texsql.sql.clear;
pr006.texsql.sql.add('insert into fpd011 (codemp, codfun, mesano, datven, totven, torven, tofven, totdes, tordes, tofdes, valliq, varliq, vafliq) values (' +
#39 + fpd005codemp.asstring + #39 + ', ' +
#39 + fpd005codfun.asstring + #39 + ', ' +
#39 + inttostr(wfolmes) + inttostr(wfolano) + #39 + ', ' +
->#39 + inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring + #39 + ', ' +
#39 + '0.00' + #39 + ',' +
#39 + '0.00' + #39 + ',' +
#39 + '0.00' + #39 + ', ' +
#39 + formatfloat('#######0.00',wvallan) + #39 + ',' +
#39 + formatfloat('#######0.00',wvallan) + #39 + ',' +
#39 + '0.00' + #39 + ', ' +
#39 + formatfloat('#######0.00',(wvallan * -1)) + #39 + ',' +
#39 + formatfloat('#######0.00',(wvallan * -1)) + #39 + ',' +
#39 + '0.00' + #39 + ')');
pr006.texsql.execute;
ESSAL LINHA TENTEI FAZER NESSAS cinco FORMAS: (obs: diapag é do tipo integer)
#39 + DATETIMETOSTR(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring) + #39 + ', ' +
#39 + STRTODATETIME(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring) + #39 + ', ' +
#39 + inttostr(wano) + '-' + inttostr(wmes) + '-' + inttostr(arq998diapag.value) + #39 + ', ' +
#39 + datetimetostr(inttostr(wano) + '-' + inttostr(wmes) + '-' + inttostr(arq998diapag.value)) + #39 + ', ' +
e até criei uma variavel do tipo tdatetime e nada.
alguem sabe me dizer como posso arrumar?
obrigado
"Deus Abençoe"
Wilton Júnior
Curtidas 0
Respostas
João Sobrinho
20/11/2012
Colega, poderia dar um ShowMessage pra ver se realmente esta gerando a informação correta:
ShowMessage(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring);
Espero ter ajudado.
ShowMessage(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring);
Espero ter ajudado.
GOSTEI 0
Claudia Nogueira
20/11/2012
Qual o banco de dados?
Tenta assim:
Tenta assim:
QuotedStr(IntToStr(wano) + '-' + IntToStr(wmes) + '-' + arq998diapag.asstring))
GOSTEI 0
Wilton Júnior
20/11/2012
JoaoSHi, obrigado pela sua ajuda.
Encontrei o erro, em um exemplo estava mostrando 30-11-5, por isso não estava gravando.
Assim fiz dessa forma para que gravasse:
FormatDateTime('dd/mm/yyyy', strtodatetime(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring))
E funcionou.
Muito obrigado pela sua ajuda.
"Deus Abençoe"
Encontrei o erro, em um exemplo estava mostrando 30-11-5, por isso não estava gravando.
Assim fiz dessa forma para que gravasse:
FormatDateTime('dd/mm/yyyy', strtodatetime(inttostr(wano) + '-' + inttostr(wmes) + '-' + arq998diapag.asstring))
E funcionou.
Muito obrigado pela sua ajuda.
"Deus Abençoe"
GOSTEI 0
Wilton Júnior
20/11/2012
Esquece que eu citei anterior só consegui mudar a mensagem de erro para outra.
Claudia respondendo sua pergunta estou usando sqlserver e o campo é tipo datetime.
Claudia respondendo sua pergunta estou usando sqlserver e o campo é tipo datetime.
GOSTEI 0
Claudia Nogueira
20/11/2012
Tenta assim:
QuotedStr(FormatDateTime('yyyy-mm-dd hh:mm:ss', StrToDate(arq998diapag.asstring + '/' + IntToStr(wmes) + '/' + (IntToStr(wano)))))GOSTEI 0
Wilton Júnior
20/11/2012
Novo erro agora Claudia, sintaxe incorreta, já inverti ele de tudo jeito e continua dando sintaxe incorreta.
GOSTEI 0
Wilton Júnior
20/11/2012
Claudia agora deu certo, eu entendi uma coisa mas é outra coisa agora eu arrumei e tah funcionando corretamente.
opbrigado.
opbrigado.
GOSTEI 0