Hello,
Need some help with this:
I have SQL server 2000.
I run a query with the following where clause:
WHERE last_call_date >= '2006-06-01 00:00:00'
AND last_call_date <= '2006-06-02 23:59:59'
last_call_date is a datetime field.
I get results including these:
2006-06-03 00:00:00.000
why is this happening? I really don't know what to say... this for me is a
terrible thing.
Any help?
Thanks
Eduardo SicouretSorry this is the actual where clause:
WHERE last_call_date >= '2006-06-01 00:00:00.000'
AND last_call_date <= '2006-06-02 23:59:59.999'
Eduardo Sicouret
"Eduardo Sicouret" <esicouret> escribi en el mensaje
news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
> Hello,
> Need some help with this:
> I have SQL server 2000.
> I run a query with the following where clause:
> WHERE last_call_date >= '2006-06-01 00:00:00'
> AND last_call_date <= '2006-06-02 23:59:59'
> last_call_date is a datetime field.
> I get results including these:
> 2006-06-03 00:00:00.000
> why is this happening? I really don't know what to say... this for me is
> a terrible thing.
> Any help?
> Thanks
> Eduardo Sicouret
>|||Eduardo Sicouret wrote:[vbcol=seagreen]
> Sorry this is the actual where clause:
> WHERE last_call_date >=3D '2006-06-01 00:00:00.000'
> AND last_call_date <=3D '2006-06-02 23:59:59.999'
> Eduardo Sicouret
> "Eduardo Sicouret" <esicouret> escribi=F3 en el mensaje
> news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
is[vbcol=seagreen]
Use one of the following, otherwise the tail end of your date range
gets rounded up. The first example is the simplest and best IMO. If you
do use the format with both date and time then don't leave out the "T"
separator - it's important.
.=2E.
WHERE last_call_date >=3D '20060601'
AND last_call_date < '20060603'
.=2E.
WHERE last_call_date >=3D '2006-06-01T00:00:00.000'
AND last_call_date < '2006-06-03T00:00:00.000'
.=2E.
WHERE last_call_date >=3D '2006-06-01T00:00:00.000'
AND last_call_date <=3D '2006-06-02T23:59:59.997'
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Try using CONVERT(DATETIME,last_call_date,20)
Jayesh
"Eduardo Sicouret" <esicouret> wrote in message
news:OD7WGb0iGHA.836@.TK2MSFTNGP02.phx.gbl...
> Hello,
> Need some help with this:
> I have SQL server 2000.
> I run a query with the following where clause:
> WHERE last_call_date >= '2006-06-01 00:00:00'
> AND last_call_date <= '2006-06-02 23:59:59'
> last_call_date is a datetime field.
> I get results including these:
> 2006-06-03 00:00:00.000
> why is this happening? I really don't know what to say... this for me is
> a terrible thing.
> Any help?
> Thanks
> Eduardo Sicouret
>
Thursday, March 8, 2012
datetime error
Labels:
2006-06-01,
clausewhere,
database,
datetime,
error,
following,
last_call_date,
microsoft,
mysql,
oracle,
query,
run,
server,
sql,
thisi
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment