The date is just the system date but it is in american format so I had to change it to european format like so<BR>dim europeandate<BR>europeandate = day(date())&"/"& month(date())&"/"& year(date()).<BR>the variable europeandate is in a date format now and I need to convert it to a string for my sql stmt<BR>select id from table1 where datefield = '"europeandate"'"<BR>I tried europeandate.toString but that wasn't working
europeandate looks like it's already in string format.<BR>Yer select statment should be:<BR><BR>strSQL = "select id from table1 where datefield = CONVERT(datetime, <%=europeandate%>)"<BR><BR>This is assuming that datefield is of type DATETIME of course. If datefield is a string in table1, then you should just use yer variable. No need to do any toString or other such nonsense.<BR>
the datefield in the table is a string but europeandate is not a string as for as I can see because<BR>SELECT (ID) FROM [table1] where datefield = '"&europeandate&"'"<BR>ain't working.<BR>However if I type in <BR>SELECT (ID) FROM [table1] where datefield = '30/01/2001'" I get a result and when I write out europeandate I get 30/01/2001<BR>
Have you tried writing out the entire SELECT statement that uses eurpoeandate?<BR><BR>For instance if you have strSQL="SELECT ...."<BR>Do a response.write strSQL and make sure that it looks just like <BR>SELECT (ID) FROM [table1] where datefield = '30/01/2001'
i have just discovered that, that is the problem. The date in SQL server is 30/01/2001 but the date in my program is 30/1/2001. I guess the easiest thing to do is to format the date to put in a 0 if Day(Date) is < 10
Then you must have the date in SQL server defined as a CHAR or VARCHAR. If it were a DATETIME, SQL wouldn't care whether the 0 is there or not. But if it were a DATETIME, you would have to do a CONVERT on yer variable.