Hi Diane, Why don't you create a stored procedure with your query in?, just pass the paramaters through that you need to run it then. Maybe start with a simple one first.
Also check what sql is using for a dateformat. Your server settings will also influence it. Last time I had this error was becuase sql was set to yyyy-mm-dd and I had dd-mm-yyyy. The cast functionality is correct sql function to use to convert it to date Sonja -----Original Message----- From: Diane Schips [mailto:[EMAIL PROTECTED] Sent: 14 July 2003 06:59 PM To: [EMAIL PROTECTED] Subject: [wdvltalk] RE: date problems in conversion from Access to SQL I tried the cast. Now I'm getting a "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value" error. The actual SELECT string sent was: SELECT [DATE OF BIRTH], [FIRST NAME], [LAST NAME] FROM members WHERE (DATEPART(mm, cast([DATE OF BIRTH] as datetime)) = 3 AND DATEPART(dd, cast([DATE OF BIRTH] as datetime)) > 20 ) OR (DATEPART(mm, cast([DATE OF BIRTH] as datetime)) = 4 AND DATEPART(dd, cast([DATE OF BIRTH] as datetime)) < 20 ) What am I doing wrong? Diane -----Original Message----- From: Rajput, Goutam [mailto:[EMAIL PROTECTED] Sent: Monday, July 14, 2003 12:29 PM To: [EMAIL PROTECTED] Subject: [wdvltalk] RE: date problems in conversion from Access to SQL Like I said change the datatype to datetime or use cast or convert functions for DOB fields. Also Datevalue is not a T-SQL function it is VB-Script function. SELECT [DATE OF BIRTH], [FIRST NAME], [LAST NAME] FROM members WHERE (DATEPART(mm, cast([DATE OF BIRTH] as datetime)) = 3 AND DATEPART(dd,cast([DATE OF BIRTH] as datetime)) > 20 ) OR (DATEPART(mm,cast([DATE OF BIRTH] as datetime)) = 4 AND DATEPART(dd,cast([DATE OF BIRTH] as datetime)) < 20 ) ____ * The WDVL Discussion List from WDVL.COM * ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% ___________________________________________________________________________________________________ The views expressed in this email are, unless otherwise stated, those of the author and not those of the FirstRand Banking Group or its management. The information in this e-mail is confidential and is intended solely for the addressee. Access to this e-mail by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted in reliance on this, is prohibited and may be unlawful. Whilst all reasonable steps are taken to ensure the accuracy and integrity of information and data transmitted electronically and to preserve the confidentiality thereof, no liability or responsibility whatsoever is accepted if information or data is, for whatever reason, corrupted or does not reach its intended destination. ________________________________ ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
