Re: I need some help here
- From: "Joseph Byrns" <josephbyrns@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Apr 2005 15:09:06 +0100
That's because it is getting the American and European dates mixed up, if
you do:
Convert.ToDateTime("13/4/2005")).ToLongDateString
it will work fine. Or you can do as Hans suggested and enter it as a date
object in the parameter.
New SqlParameter("@date", aDateObject)
"Chris" <Chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2D8CAA46-AE2C-4B68-A80B-EA2D97E0655F@xxxxxxxxxxxxxxxx
> Hi,
> When I try
>
> New SqlParameter("@date",
> (Convert.ToDateTime("4/13/2005")).ToLongDateString)
>
> I get the error
>
> Error onverting datatype nvarchar to datetime.
>
> "Joseph Byrns" wrote:
>
>> 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
>>
>>
>>
.
- Follow-Ups:
- Re: I need some help here
- From: Chris
- Re: I need some help here
- References:
- I need some help here
- From: Chris
- Re: I need some help here
- From: Joseph Byrns
- Re: I need some help here
- From: Chris
- I need some help here
- Prev by Date: Re: DataReader... and ...
- Next by Date: image as form background
- Previous by thread: Re: I need some help here
- Next by thread: Re: I need some help here
- Index(es):
Relevant Pages
|