Current location: Hot Scripts Forums » Programming Languages » ASP » Error: Syntax error converting datetime from character string.


Error: Syntax error converting datetime from character string.

Reply
  #1 (permalink)  
Old 08-22-03, 12:04 AM
Han84 Han84 is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Error: Syntax error converting datetime from character string.

Hi everyone,

I have problem displaying my data in an asp page. The problem lie in the sql statment when i need to use the date as one of my condition for retrieving the data.. I haf send the code in the attachment for easy viewing.. But i will highlight the code that is causing the problem here...


The code is


<script language="javascript">
function openwindow(theURL, WinName, features)
{
window.open(theURL, WinName, features);
}
</script>

<!-------------------------------------------------------------------------- FOR EDIT - START -->
<% function aa_edit() %>
.
.
.


On Error Resume Next

if (request.form("startdate") = "") then
xdate = now()
tempsdate= dateAdd ("D",-7,xDate)
sday = day(tempsdate)
syear = year(tempsdate)
smonth = MonthName(month(tempsdate))

tempedate= now()
eday = day(tempedate)
emonth = MonthName(month(tempedate))
eyear = year(tempedate)

startdate = sday&"-"&smonth&"-"&syear
enddate = eday&"-"&emonth&"-"&eyear

else

tempsdate= request.form("Startdate")
sday = day(tempsdate)
syear = year(tempsdate)
smonth = MonthName(month(tempsdate))
tempsmonth = month(tempsdate)

tempedate= request.form("Enddate")
eday = day(tempedate)
emonth = MonthName(month(tempedate))
tempemonth = month(tempedate)
eyear = year(tempedate)

if datediff("D", tempsdate, tempedate) <= 0 then%>
<script language="javascript">
window.open("../inc/errordate.asp", "Error", "width=350,height=140");
</script>
<%end if

startdate = sday&"-"&smonth&"-"&syear
enddate = eday&"-"&emonth&"-"&eyear
end if

On Error Goto 0

set rs2 = server.createobject("ADODB.recordset")

sql2 = " SELECT DISTINCT LotNo, quantity, Water, HOCA, TotalNitrogen , Oil , ASH, HOSU, Iron, Assay, Color , Fines, ParticleSize , Approved, date_authorized, Allotted, emft, special_lot from aalabresult where approved=1 and Coa_Selected = 0 and date_authorized between '"&startdate&"' and '"&enddate&"' ORDER BY LotNo "


%>

.
.
.
<% end function %>
<!-- END -->



Hope to hear from your answer soon,
Thx alot
Reply With Quote
  #2 (permalink)  
Old 08-22-03, 04:59 AM
greeny greeny is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
sql2 = "SELECT DISTINCT LotNo, quantity, Water, HOCA, TotalNitrogen , Oil, ASH, HOSU, Iron, Assay, " & _
       "Color, Fines, ParticleSize, Approved, date_authorized, Allotted, emft, special_lot " & _ 
       "FROM aalabresult WHERE approved = 1 AND Coa_Selected = 0 AND " & _
       "date_authorized BETWEEN #" & startdate & "# AND #" & enddate & "# ORDER BY LotNo"
__________________
thanks,
valen@efusian.co.uk

Last edited by greeny; 08-22-03 at 05:09 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 03:17 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.