Date

  • Thread starter Thread starter Amal Ismail
  • Start date Start date
A

Amal Ismail

hello

i'm inquiring about something .. hope to find help here
i'm using ASP.NET Mobile web application using c#
And i'm facing a problem , i use SQL server Database
I've table inside it a column of type smalldatetime &
i can't change its format , and in the mobile webform
i've a textbox the user enter a string on the format
mm/yyyy ... i need to compare it to the date in the

database And show a certain value to the user depending
on the entered date so i either need to change the date
format in the DB to string or the string that the user
enter to date format
i've tried to use this phrase in the select statement
ex :
string Value_select_text="select value from
MONTHLY_Indicators_Value where convert(varchar(30),month
(indicator_date))+'/'+convert(varchar(30),year
(indicator_date))="+MyDate;

where MyDate is the string that the user entered but it
gave me a strange error
Syntax error converting the varchar value '1/2002' to a
column of data type int.
supposing that the user entered 01/2002 as a date

Best Regards
Amal
 
Hi Amal,

It might be because you are trying to compare two strings in the SQL where clause using the equals (=) sign. To compare two strings, you might want to use
something like:

select * from xyz where 'abc' is 'def'; or select * from xyz where 'abc' like 'def';

If this is the case, you will have to enclose the strings in single quotes. If this does not work, please let me know more about the DB table structure as well.

Thanks.
--------------------
Content-Class: urn:content-classes:message
From: "Amal Ismail" <[email protected]>
Sender: "Amal Ismail" <[email protected]>
Subject: Date
Date: Tue, 6 Jul 2004 04:26:20 -0700
Lines: 29
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcRjTA+5f1NcLeJKS/GIFNUOqrlLtg==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:256725
NNTP-Posting-Host: tk2msftngxa11.phx.gbl 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

hello

i'm inquiring about something .. hope to find help here
i'm using ASP.NET Mobile web application using c#
And i'm facing a problem , i use SQL server Database
I've table inside it a column of type smalldatetime &
i can't change its format , and in the mobile webform
i've a textbox the user enter a string on the format
mm/yyyy ... i need to compare it to the date in the

database And show a certain value to the user depending
on the entered date so i either need to change the date
format in the DB to string or the string that the user
enter to date format
i've tried to use this phrase in the select statement
ex :
string Value_select_text="select value from
MONTHLY_Indicators_Value where convert(varchar(30),month
(indicator_date))+'/'+convert(varchar(30),year
(indicator_date))="+MyDate;

where MyDate is the string that the user entered but it
gave me a strange error
Syntax error converting the varchar value '1/2002' to a
column of data type int.
supposing that the user entered 01/2002 as a date

Best Regards
Amal


--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
 
Back
Top