On Sat, Jun 26, 2010 at 12:23 PM, MB Software Solutions, LLC
<[email protected]> wrote:
> Grigore Dolghin wrote:
>> Go for Date datatype if you're using SQL Server 2008. It was a PITA to get 
>> the date part out of the Datetime field in previous versions, especially 
>> when working with date intervals. (If the user enters 2010/06/26 in the 
>> textbox, the server stores it as 2010/06/26 00:00:00, which is smaller than 
>> any other value in the same day. And if you need all the records containing 
>> values in range 2010/06/01 - 2010/06/26, you could not use BETWEEN, but had 
>> to resort to an expression like this: Where OrderDate >= '2010/06/01' And 
>> OrderDate < '2010/06/27')
>
>
> I never understood why they made it so hard like that.  Using that
> DATEDIFF or whatever function it was was always such a PITA.  Good to
> hear they're using a simple DATE field type now.  Was that new in 2008?
-----------------------
For both of you.

http://www.lmgtfy.com/?q=SQL+Server+cast+datetime+as+date

This has been the standard:
SELECT CONVERT(VARCHAR(10),GETDATE(),111) and you can change the that
number to fix your output.
SELECT CONVERT(VARCHAR(10),GETDATE(),110)

SELECT CONVERT(VARCHAR(10),GETDATE(),112)


Yes Date alone it was new for 2008.

Now what is so hard about datediff?

DATEDIFF ( datepart ,startdate ,enddate )

The datepart allow you to set what is important in your diff.  Are you
interested in seconds because this is a date-time field or are you
looking for years.  Just put in the proper parameter and you get the
results you want.



-- 
Stephen Russell

Sr. Production Systems Programmer
CIMSgts

901.246-0159 cell

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to