title: Convert varchar=> Datetime stored procedure
body: <p>I would like to convert a <code>varchar</code> into <code>Datetime</code> datatype (DATESX = UDDT, datetime). I know what I have to use : </p>
  
  <pre><code>CONVERT(datetime, '@adx_en_cours_etude') 
  </code></pre>
  
  <p>but I don't see where I can add this convert function ...</p>
  
  <pre><code>DECLARE @return_value int
  
  EXEC    @return_value = [dbo].[ps_ListingElem]
      @aid_cdi = 5058,
      @adx_en_cours_etude  = '2007-05-23 00:00:00.000'
  
  SELECT  'Return Value' = @return_value
  GO
  
  
  /*My stored procedure :*/
  ALTER  PROCEDURE [dbo].[ps_ListingElem]
      @aid_cdi ID, /* uddt */
      /* (DATESX = User defined datatype = datetime type)  */
      @adx_en_cours_etude  DATESX,    
  AS
  BEGIN
    SELECT
      pc_sup.dt_deb,
      pc_sup.dt_fin,
      pc_sup.id_type_produit,
    FROM     pc_sup
      INNER JOIN type_prod ON pc_sup.id_type_prod = type_prod.id_type_prod
      INNER JOIN cdi_type_prod ON type_prod.id_type_prod = cdi_type_prod.id_type_prod
  
    WHERE   cdi_type_prod.id_cdi = @aid_cdi
        AND   (@adx_en_cours_etude IS NULL 
        OR    pc_sup.dt_deb &lt;= @adx_en_cours_etude  
        AND   pc_sup.dt_fin &gt;= @adx_en_cours_etude ) 
  END
  </code></pre>