On Mar 13, 2:16 pm, "Aaron Bertrand [SQL Server MVP]"
<ten....@dnartreb.noraa> wrote:
> Is the following correct?
>
[quoted text clipped - 46 lines]
> Access. And for single characters, it is an underscore _ not ? like in
> Access.
I really appreciate the help. You are exactly right. I was looking
at MS Access. I made the changes according to what you listed. My
error "SQL0180N The syntax of the string representation of a datetime
value is incorrect. SQLSTATE=22007". I'm using yyyy-mm-dd. I can
see the dates in a column on another query as 2007-06-17
23:00:13.827584 which is yyyy-mm-dd time(i guess).
My attempt:
SELECT <column_list>
FROM ABXDB01.mgd_req_holdg
WHERE ABX_REQ_BUCKT = 'OK'
AND CMPL_Q_DT > ''2008-03-01TO5:00:00';
tried:
AND CMPL_Q_DT > ''2008-03-01';
tried:
AND CMPL_Q_DT > ''2008-03-01%';
Ty
Kalen Delaney - 13 Mar 2008 22:05 GMT
Ty
Dates can be very tricky to work with, as you're finding out. The display
format for dates may have nothing to do with how SQL Server interprets an
input string as a date. Input and output formatting for dates can be
controlled completely separately.
Please read Tibor's great article:
The Ultimate Guide to the Datetime Datatypes
http://www.karaszi.com/sqlserver/info_datetime.asp

Signature
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://DVD.kalendelaney.com
On Mar 13, 2:16 pm, "Aaron Bertrand [SQL Server MVP]"
<ten....@dnartreb.noraa> wrote:
> Is the following correct?
>
[quoted text clipped - 50 lines]
> Access. And for single characters, it is an underscore _ not ? like in
> Access.
I really appreciate the help. You are exactly right. I was looking
at MS Access. I made the changes according to what you listed. My
error "SQL0180N The syntax of the string representation of a datetime
value is incorrect. SQLSTATE=22007". I'm using yyyy-mm-dd. I can
see the dates in a column on another query as 2007-06-17
23:00:13.827584 which is yyyy-mm-dd time(i guess).
My attempt:
SELECT <column_list>
FROM ABXDB01.mgd_req_holdg
WHERE ABX_REQ_BUCKT = 'OK'
AND CMPL_Q_DT > ''2008-03-01TO5:00:00';
tried:
AND CMPL_Q_DT > ''2008-03-01';
tried:
AND CMPL_Q_DT > ''2008-03-01%';
Ty
Aaron Bertrand [SQL Server MVP] - 18 Mar 2008 03:15 GMT
My attempt:
SELECT <column_list>
FROM ABXDB01.mgd_req_holdg
WHERE ABX_REQ_BUCKT = 'OK'
AND CMPL_Q_DT > ''2008-03-01TO5:00:00';
Why do you have '' and not ' at the beginning? Did you notice that you
typed TO even though the code sample I provided had T0 (T zero)? How about:
AND CMPL_Q_DT >= '2008-03-01T05:00:00';
AND CMPL_Q_DT > ''2008-03-01';
It's confusing, annoying, and not very intuitive, but when you are using
*just* a date as a literal, you should use YYYYMMDD in that case. And
again, you need to not use two single quotes to start a string! Also,
unless you meant to explicitly exclude rows marked at midnight, but include
rows from 12:00:00:003 AM on, you probably want to use >= as opposed to >.
How about:
AND CMPL_Q_DT >= '20080301';
AND CMPL_Q_DT > ''2008-03-01%';
No, dates are not strings, and wildcards do not work this way. I strongly
recommend reading the article that Kalen and I both pointed out to you.
It's not going to solve all of your problems, but it should help you
understand them.
A
Ty - 21 Mar 2008 20:54 GMT
On Mar 17, 9:15 pm, "Aaron Bertrand [SQL Server MVP]"
<ten....@dnartreb.noraa> wrote:
> My attempt:
> SELECT <column_list>
[quoted text clipped - 26 lines]
>
> A
Got it!!! It is a timestamp. I used the
'2008-03-01-00.00.00.000000'