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 6 1268
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" <Ch***@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.com... 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
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).
If you use parameters to call that sp, then you can just use
a DateTime value. No need to convert to string.
"Chris" <Ch***@discussions.microsoft.com> wrote in message news:39**********************************@microsof t.com...
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
the *debugger* is *displaying* the DateTime value as mm/dd/yyyy,
it doesn't store it internally as string.
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
--
Hans Kesting
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" <Ch***@discussions.microsoft.com> wrote in message news:39**********************************@microsof t.com... 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
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" <Ch***@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com... 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" <Ch***@discussions.microsoft.com> wrote in message news:39**********************************@microsof t.com... > 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
This is my setup
Private Sub GetReport(ByVal sDate As String)
.....New SqlParameter("@date",
(Convert.ToDateTime(sDtae)).ToLongDateString)
End Sub
And I am calling it like this
GetReport(txtDate.text)
txtDate receives the date in the format 4/13/2005
This doesn't work.
"Joseph Byrns" wrote: 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" <Ch***@discussions.microsoft.com> wrote in message news:2D**********************************@microsof t.com... 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" <Ch***@discussions.microsoft.com> wrote in message news:39**********************************@microsof t.com... > 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
Yes, it is just that the date is the wrong way round (mm/dd/yyyy instead of
dd/mm/yyyy), presumably, txtDate is a text box, can you not use a
DateTimePicker instead? Or drop down lists for the date, that way you can
ensure the date is in the correct order before you start?
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com... This is my setup
Private Sub GetReport(ByVal sDate As String)
....New SqlParameter("@date", (Convert.ToDateTime(sDtae)).ToLongDateString)
End Sub
And I am calling it like this
GetReport(txtDate.text)
txtDate receives the date in the format 4/13/2005
This doesn't work.
"Joseph Byrns" wrote:
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" <Ch***@discussions.microsoft.com> wrote in message news:2D**********************************@microsof t.com... > 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" <Ch***@discussions.microsoft.com> wrote in message >> news:39**********************************@microsof t.com... >> > 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 >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Robert Maas, see http://tinyurl.com/uh3t |
last post by:
System login message says PHP is available, so I tried this:
http://www.rawbw.com/~rem/HelloPlus/h.php
It doesn't work at all. Browser just shows the source.
What am I doing wrong?
|
by: James Hong |
last post by:
Help please, I try to sending an email from my html page using the java
applet.
but it give error on most of the PC only very few work, what is the error i
make
the java applet show as below
...
|
by: mike |
last post by:
Hello,
After trying to validate this page for a couple of days now I was
wondering if someone might be able to help me out. Below is a list of
snippets where I am having the errors.
1. Line 334,...
|
by: John Flynn |
last post by:
hi all
i'm going to be quick i have an assignment due which i have no idea how to
do. i work full time so i dont have the time to learn it and its due date
has crept up on me ..
As follows:...
|
by: Mark Kamoski |
last post by:
Hi--
Please help.
I need a code sample for bubble sort.
Thank you.
--Mark
|
by: Chad Z. Hower aka Kudzu |
last post by:
A few of you may recognize me from the recent posts I have made about Indy
<http://www.indyproject.org/indy.html>
Those of you coming to .net from the Delphi world know truly how unique and...
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
Brilliant technology helping those most in need Inbox
Reply
U S Contractors Offering Service A Non-profit
show details
10:37 pm (1 hour ago)
Brilliant technology helping those most in need ...
|
by: mike |
last post by:
I help manage a large web site, one that has over
600 html pages... It's a reference site for ham radio
folks and as an example, one page indexes over
1.8 gb of on-line PDF documents.
The site...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |