Link to home
Start Free TrialLog in
Avatar of HARLIBRA
HARLIBRA

asked on

select error:syntax error during explicit conversion of varchar value '11-13-200723:59:59' to a datetime field

This a datawindow sql for a report.It looks like somehow the date conversion code we have in the query is concatenating the date/time correctly in some cases and others it doesnt work and we get no space between them.  It happens when we enter dates greater than 11/10/2007 for the to-date
I was thinking of  padding a space to the beginning of the time fields hardcoded in the SQL.
What you guys think.
select .....
where
 (itemhst.crdtstmp >= convert(datetime,convert(varchar(10),:a_da_fromdate) + '00:00:00')) and
         (itemhst.crdtstmp <= convert(datetime,convert(varchar(10),:a_da_todate) + '23:59:59')) 
 
crdtstmp  is a datetime field. The database is Sybase ASE 12.5. Powerbuilder ver 9

Open in new window

datawinerror.bmp
ASKER CERTIFIED SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of grant300
grant300

Test the SQL in an interactive tool first so you don't get bound up with the reporting facility.  It will make things much easier.

Regards,
Bill