Solved

AND ((cs.dtDateCreated >= '2007-11-07 00:00:00.000' AND cs.dtDateCreated <= '2008-01-15 00:00:00.000' + 1)

Posted on 2007-11-30
4
231 Views
Last Modified: 2010-03-20
I assume I need to cast?

AND ((cs.DateCreated >= '2007-11-07 00:00:00.000' AND cs.DateCreated <= '2008-01-15 00:00:00.000' + 1)
0
Comment
Question by:dba123
  • 2
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 20385523
yes:

AND cs.DateCreated >= convert(datetime, '2007-11-07 00:00:00.000', 120)
AND cs.DateCreated < dateadd(day, 1, convert( datetime, '2008-01-15 00:00:00.000' ,120))
0
 
LVL 1

Author Comment

by:dba123
ID: 20385535
thank you.
0
 
LVL 1

Author Comment

by:dba123
ID: 20385540
got it to work this way as well
AND ((cs.DateCreated >= CAST('2007-11-07 00:00:00.000' as varchar) AND cs.DateCreated <= CAST('2008-01-15 00:00:00.000' AS varchar))
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20385558
>got it to work this way as well
this might work, but it is using implicit conversion format.
you should prefer the explicit way I suggested, it will save you from unexpected trouble you could get into later... on other servers ... etc...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Help 27 67
How to use three values with DATEDIFF 3 42
SQL Syntax Grouping Sum question 7 35
Need help separating values from a column and creating a new record 6 40
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question