Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Update Problem in SQL 2000 Database

Status
Not open for further replies.

MinalMaurice

Programmer
Apr 20, 2005
14
GB
I am migrating from Microsoft Access to Microsoft SQL as my database.

I'm getting problems with dates - an error is returned "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value."

This is due to the line of code

Set LastVisit = '#TodayDate#' Where ID = #MemberResponse.ID#

based on
<CFSET TodayDate = '#dateformat(Now(), 'dd/mm/yyyy')#'>

SQL 2000 doesn't like unlimited dates, so that the above CFSET needs to be changed to prevent the error occurring.

Any ideas on how to modify that CFSET?

Thanks in advance.
 
try

set lastVisit = ###todayDate### where ID = #memberResponse.id#

also, your cfset has unneeded quotes and pound signs.

for best practice your cfset should look like this...
<CFSET TodayDate = dateformat(Now(), 'dd/mm/yyyy')>

Beware of programmers who carry screwdrivers.
 
Don't worry about the cfset statement.
Code:
Set LastVisit = <cfqueryparam value="#Now()#" cfsqltype="CF_SQL_DATE"> 
Where ID = #MemberResponse.ID#



Hope This Helps!

ECAR
ECAR Technologies, LLC

"My work is a game, a very serious game." - M.C. Escher
 
doh, keep forgetting about cfqueryparam in fixing "data type mismatch" errors. good post.

Beware of programmers who carry screwdrivers.
 
Thanks - that worked a treat.

Are there any other examples of SQL_Type that I should be urgently aware of?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top