problem in using the convert function for date

i have a problem in sybase.

select convert(char(10), dbo.classes.start_date, 101) from dbo.classes 
where dbo.classes.class_id = 316600
AND	 convert(char(10), dbo.classes.start_date, 101) >= '07/01/2001' ;

i have a field start_date in the classes table.the field start date is a
datetime field.

i wanted to select the dates > '07/01/2001' from the classes table.there is a
record in the classes table with the start_date value as
7/2/99 00:00:00

when i run the above query it gives me the record with 7/2/199 value also which
i dont want.can you check is there anything wrong in the query?


thanks

andrew

---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp
0
andrew
7/10/2001 4:40:08 PM
sybase.powerbuilder.database 9855 articles. 0 followers. Follow

1 Replies
298 Views

Similar Articles

[PageSpeed] 21

It's because you're converting the date to a string and doing a string
comparison.  You should leave it as a date and do a date comparison.
Something like:
....
AND dbo.classes.start_date >=  cast('07/01/2001' as date)


--
Simon Caldwell
Get Real Systems Ltd
Holtby Manor, Stamford Bridge Road, York, YO19 5LL
Tel 01904 481999 Fax 01904 481666
Visit us at www.getrealsystems.com

Specialists in e-Procurement and supply chain technology


"andrew" <andrew_sridhar7@yahoo.com> wrote in message
news:gthI77VCBHA.250@forums.sybase.com...
> i have a problem in sybase.
>
> select convert(char(10), dbo.classes.start_date, 101) from dbo.classes
> where dbo.classes.class_id = 316600
> AND convert(char(10), dbo.classes.start_date, 101) >= '07/01/2001' ;
>
> i have a field start_date in the classes table.the field start date is a
> datetime field.
>
> i wanted to select the dates > '07/01/2001' from the classes table.there
is a
> record in the classes table with the start_date value as
> 7/2/99 00:00:00
>
> when i run the above query it gives me the record with 7/2/199 value also
which
> i dont want.can you check is there anything wrong in the query?
>
>
> thanks
>
> andrew
>
> ---== Posted via the PFCGuide Web Newsreader ==---
> http://www.pfcguide.com/_newsgroups/group_list.asp


0
Simon
7/11/2001 8:16:33 AM
Reply:

Similar Artilces:

Problem In Converting To Date (From Database)
hi all! what i'm trying to do, is to display only the date that is read from the database (without the time together). the snippet of my code is as below: <tr> <td align="right"> <asp:Label id="lblSDOB" runat="server">Date Of Birth :</asp:Label></td> <td> <%=Dr("Staff_DOB").ToString%></td> </tr> the code above does not generate any error, but it display both date and time, but i only want it to display the date in mm/dd/yyyy format. so, i've tried a few me...

converting date time format for use in other database such as salesforce.com
Hi all- I'm curious if somebody can tell me how to format a datetime from YYYY-MM-DD 12:00:00 PM to something like this...  2008-10-07T21:48:00.000Z?  Any help is greatly appreciated. Thanks, BW Isn't that ISO 8601? If I remember well, its something like: DateTime.Now.ToString("o"); Of course, replace DateTime.Now by your date structure, but the format with a lower case "o" should give you that I beleive. EDIT: Oh wait, its Universal Sortable. Use "u" instead of "o". EDIT 2: Confusing even myself here... the Z at the end w...

Display date in PowerBuilder using regional settings date(Thai
Hi all, Need help on how to display date in PowerBuilder with an editmask following the date format in the regional settings. We have a client using buddhist calendar and should display the year as 2552 if 2009 is the year. Problem is, even if I use [date][time] edit mask, PB still displays the date as 25/02/2009 wherein it should be 25/02/2009. Thank you in advance, please help, its urgent. Willie This solution was posted to Experts Exchange by Vikas Dixit (so I cannot take credit) Although this was not specific for the Thai Calendar, it may provide the tools you need to ge...

problems converting to asp.net from using a SIMPLE Response.Write and a lil database connectivity
Hi all, this is driving me absolutely insane here since i can't find a sane answer to my question. I'm used to working with ASP and lets say i have a database which stores my page content and i want to have my .asp page display content based on the pageid it has.. it used to be so simple.. just do a lil' select from the database where the ID is the same as the pageid.. then with a: response.write ("this is the title:" & rs("title")) response.write (rs("content") you could throw out the entire content and title in the page.. now with this "...

Using CONVERT function to convert NUMERIC to VARCHAR
I am creating a trigger on a table where 2 columns are defined as numeric. This trigger captures the data and inserts it into another table where I want to combine the numeric data with a statement. I've tried using the CONVERT function, but it is giving me a mis-matched token error. I've looked through the documentation online, but it is not really helping me or I'm not understanding correctly. I've pasted a snippet of what I'm trying to do without using the CONVERT function. **user_level and region_id are the numeric values** select @whatchanged = case ...

How to use Convert date statement in cmdInsert.Parameters.Add("Date",SqlDbType.DateTime).Value = date
HiI am using SQL 2005, VB 2005I am trying to insert a record using parameters using the following code as per MotLey suggestion and it works finestring insertSQL; insertSQL = "INSERT INTO Issue(ProjectID, TypeofEntryID, PriorityID ,Title, Area) VALUES (@ProjectID, @TypeofEntryID, @PriorityID ,@Title, @Area)"; cmdInsert SqlCommand; cmdInsert=new SqlCommand(insertSQL,conn); cmdInsert.Parameters.Add("@ProjectID",SqlDbType.Varchar).Value=ProjectID.Text; My query is how to detail with dates my previous code wasinsertSQL += "convert(datetime,'" + DateTime.Now.ToSt...

Using a date function to declare a variable used in a SQL query
Hi all can you help me, I know that I am doing some thing wrong. What I need to do is set a variable to the current date so I can use it in a SQL query to an access database. This is what I have so far <script runat="server""> Sub Page_Load dim --all the variables for my sql connections-- dim ff1 As Date then my sql connection and queries sql="SELECT FullRate, " & ff1 &" FROM table1 WHERE hotelnumber = " & hotel This works is I set ff1 as a string and specify the string (my column headings are set as dates in my table) dim ff1 As string ff1="30/01/2006" but I need...

problem with converting to date
this._thedate= Convert.ToDateTime(ds.Tables[0].Rows[0]["thedate"].ToString()); In the above line, it will work if there is a value in thedate. however, if it is null, then it can't convert to DateTime. Any suggestions on how to keep this from blowing up if thedate is null? you need to check for null first and then decide what value you will substitute when that situation occurs.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/...

Date Convert Problem
Hi, I have a date in a tabel. I have the next Code: DateTime date_sinds = ((DateTime) reader["date"]).ToString(); lblAantalDagen.Text = (DateTime.Compare(System.DateTime.Today,date_sinds)).ToString(); But i have the follow error: Cannot implicitly convert type 'string' to 'System.DateTime' Can someone help me? Thanks Tom Hi topi, I think the problem lies in the DateTime date_sinds = ((DateTime) reader["date"]).ToString(); You convert the reader["date"] to a DateTime value only to convert it to a string and then assign...

Problem with the date function
How to calculate the exact date before certain number of days.Say for example want to get the date 50 days before today's date.Thanks You may try this: DATEADD(DAY,-50,GETDATE()) Regards Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

Database in use problem
I have an sql server 2005 express db that will not let me restore, delete, or detach it. It tells me the db is in use, it's on a single pc and not being used by anyone. I have Management Studio Express that I'm working with. I have disconnected several times, and rebooted. Can anyone suggest anything to try?  Thank youJackxxx Di you try to stop the database to be able to delete or detach?CheersAlMy BlogMapStats.NETPlease click on 'Mark as Answer' if this post answered your question!   Hi Jack  opne MS SQL Query analyser  select master database &n...

Problem with date function
hi guys. I am developing a project in ASP.NET using VB.NET. The project is about e-banking. Here i have a table in my database named as "tansaction". This table contains all the transaction details for a particular account. There is a query for the system to "find all the transactions which took place in the current month". I have an attribute "transaction date" in the transaction table which has the date of the transaction. now what i thought of doing is 1) To retrieve the system date using the following code Dim dtmDate As DateTime dtmDate = Da...

CONVERT function use
I'll go right to the point: I have a textbox in wich the user can seize a "money" value. But when i'm doing the INSERT command, it fails and says I cannot implicitely convert nvarchar data (mytextbox.text) to money data. I don't know how to handle this... objCmd = New SqlCommand("INSERT INTO tbl_appel_service_pieces " & _ "(fld_nom_piece, fld_quantite, fld_prix, fld_description, fld_num_appel) " & _ "VALUES (@fld_nom_piece, @fld_quantite, @fld_prix, @fld_description, @fld_num_appel)", objConn) objCmd.Parameters.Add(&qu...

Date convert function
Dear All, I used following queary form shows all record greter than date. But in this queary it match with only day means with only '26' not with hole date, It shows record only greater th 26 but all years. I want to match with exact date. How ? select TransId,Account,Debit,Credit,CONVERT( varchar(12),RefDate,105) from JDT1 where (CONVERT( varchar(12),RefDate,105) >= '26-10-2006')  hitry this select TransId,Account,Debit,Credit,CONVERT( varchar(12),RefDate,105) from JDT1 where (CONVERT( varchar,RefDate,103) >= '26-10-2006') ...

Web resources about - problem in using the convert function for date - sybase.powerbuilder.database

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

TV binging, exercise skipping linked to poor cognitive function
... their fit, less TV-addicted counterparts. In particular, couch potatoes had slightly lower brain processing speeds and worse executive function, ...

iPhone best tricks and functions - Business Insider
Your iPhone can do a lot more than you think.

Learning F# – Passing Parameters to Functions
One of the first issues I faced when learning F# was finding out how to specify multiple parameters to a function. While this might sound obvious ...

HPE Offers Catalog of Virtual Network Functions for Telcos
The vendor's OpenNFV Solution Portal gives carriers a single place to find a range of VNFs that are pre-tested to run on their networks.

7 Useful Technical SEO Functions For Your E-commerce Website
This article was co-authored by Mate Dyekiss, SEO Strategist at IMI. An e-commerce website can create all the technical SEO issues onecan imagine: ...

Using AWS Lambda functions to create print ready files
... going to tell you about our processing architecture as well as at a recent performance improvement with the integration of AWS Lambda functions. ...

Madras HC asks police to allow Tipu’s birth anniversary function
... Station on a petition filed by Ismail, General Secretary of Thamizhaga Makkal Jananayaga Katchi, seeking grant of permission to hold the function. ...

Colorado governor: This Planned Parenthood shooting may be a function of inflammatory rhetoric from bloggers ...
Via Grabien , skip to 4:45 of the clip below for the key bit. I naively thought we were (mostly) done with “climate of hate” stupidity after ...

Surprise: Binge-Watching TV May Cause a Decline in Brain Function
With the second season of Transparent only a few days away, some bad news awaits us: According to a recent study and common sense, probably, ...

Resources last updated: 1/3/2016 9:05:36 AM