Re: I need some help here



You need to pass the date as a date rather than a varchar, so the procedure
would look more like:

create proc test(
@date datetime)

as
begin

select name from table
where
DateEnt = @date

And I would also suggest you change the date to a long date string in the
..NET part, so if you have a date object dt send dt.ToLongDateString (rather
then the ShortDateString you are currently sending).

"Chris" <Chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:39925A92-79DB-48D8-BFB0-4DCCB9633E5E@xxxxxxxxxxxxxxxx
> Hi,
> I am storing dates in sql server in this format
>
> 2005-04-13 22:22:16.353
>
> My asp.net app is passing the date as string like this 4/13/2005
>
> to the foll sp
>
>
>
> create proc test(
> @date varchar(11))
>
> as
> begin
>
> select name from table
> where
> LEFT( CONVERT(varchar, DateEnt, 120), 10)= @date
>
> but that doesn't work only if I pass it as 2005-04-13 22:22:16.353. I
> tested
> the proc in sql server
>
> exec test '4/13/2005' but this doesn't work.
>
> exec test '2005-04-14' this works.
>
> Please advice.
>
> Thanks
> Saif


.



Relevant Pages

  • Re: I need some help here
    ... create proc test( ... a DateTime value. ... No need to convert to string. ... I am storing dates in sql server in this format ...
    (microsoft.public.dotnet.framework.aspnet)
  • I need some help here
    ... I am storing dates in sql server in this format ... to the foll sp ... create proc test( ... exec test '4/13/2005' but this doesn't work. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: I need some help here
    ... > Error onverting datatype nvarchar to datetime. ... >>> I am storing dates in sql server in this format ... >>> create proc test( ...
    (microsoft.public.dotnet.framework.aspnet)