Skip to Content.
Sympa Menu

freetds - Re: [freetds] php, mssql, datetime problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Brian Morton" <bmorton AT secureworks.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] php, mssql, datetime problem
  • Date: Tue, 30 May 2006 12:22:46 -0400

When you are storing the data in the variable, it looks like it in being
converter to varchar for display purposes. You have two options. In your
second query, I'm guessing you're using the datetime as part of a where
clause. In the where clause, change "where datetimefield =
firstRS['datetime']" to "where cast(datetimefield as varchar) =
firstRS['datetime']". The other choice is to make this happen in one query
using a join and a subselect, which may be easier.

-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Agustín Moyano
Sent: Tuesday, May 30, 2006 12:15 PM
To: freetds AT lists.ibiblio.org
Subject: [freetds] php, mssql, datetime problem

Hello everyone, I hope someone can help me.

First of all, I'm using php in a Suse 10 with Apache that connects to a
mssql.
The problem I have is that I make a select to get some data from a datetime
field. That data is stored in a variable, and when I try to use that same
data to make an other select to the same database I get the following error:


Error converting data type varchar to datetime (severity 16)

When I do that same select in a query analyzer it works ok.
Does anybody knows what the problem might be?... I'm really lost here.

Agustín.

Ps: The format of the datetime that the database gives from a select is
dd/mm/YYYY, I don't know if that's a problem..
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page