Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
251 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 1000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

972 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