Re: date comparioson in a Case statement

From: Raymond D'Anjou \(raydan\) (raydan_at_canatrade.nospamcom)
Date: 04/05/04


Date: Mon, 5 Apr 2004 16:00:50 -0400

Both "NA" and e_dt have to be the same datatype.
Try this:
> when ex.e_dt < a1.d_dt then "NA"
> else CONVERT(VARCHAR(10), e_dt, 111)
> end,

"ajmister" <ajmister@optonline.net> wrote in message
news:eTvHLk0GEHA.4012@TK2MSFTNGP09.phx.gbl...
> Hi
>
> I have a case statement where I am comparing two dates
>
> rpt_dt=
> case
> when ex.e_dt < a1.d_dt then "NA"
> else e_dt
> end,
>
> give me an error
> Syntax error during implicit conversion of VARCHAR value 'NA' to a
DATETIME
> field.
>
> rpt_dt=
> case
> when ex.e_dt < a1.d_dt then ""
> else e_dt
> end,
>
> runs successfully but I get Jan 1, 1900 values in he fields where ex.e_dt
<
> a1.d_dt .
>
> Not sure why it is extracting incorrect values.
> Ajay
>
>



Relevant Pages

  • Re: SQL Data Types (7 vs 2k)
    ... What it sounds like is they have a WHERE clause that is ... comparing two different datatypes and the proper indexes are being used. ... Andrew J. Kelly SQL MVP ... > datatype precedence in WHERE clauses in SQL2K vs. ...
    (microsoft.public.sqlserver.programming)
  • Re: Could anyone help how to convert the variables to appropriate data
    ... Compass Technology Management - www.compass.net ... Pro SQL Server 2000 Database Design - ... > Syntax error near @sintEventYear,it is a bit datatype. ...
    (microsoft.public.sqlserver.programming)
  • Re: Docmd.Openform with where condition Syntax
    ... the button on the dialog box has this on the onclick event: ... Run-time error 3705 ... Syntax error in date in query expression MCH_CASECODE = #1360# ... What is the datatype of the "MCH_CASECODE" field? ...
    (comp.databases.ms-access)
  • Re: Comparing two "identical" tables
    ... I was confusing this with another thread about comparing two columns ... of datatype TEXT. ... (Reverse address to reply.) ... "J O Holloway" wrote in message ...
    (microsoft.public.sqlserver.programming)
  • Re: What is the better method for using hash??
    ... I'd do it by measuring their memory usages, ... then comparing them. ... hashes (and is also a syntax error if you use strict). ...
    (comp.lang.perl.misc)