显示标签为“significant”的博文。显示所有博文
显示标签为“significant”的博文。显示所有博文

2012年3月8日星期四

Any significant differences between these two date CAST statements

I need to find records that have a date stamp of yesterday. I have created two where clauses that use CAST and DATETIME. Both seem to return the same results. Is either one better?

CAST(FLOOR(CAST(cc.Date AS float)) AS datetime) = CAST(FLOOR(CAST((getdate()-1) AS float)) AS datetime)

-- OR --

cast (round(cast(cc.Date as float),0,1) as datetime) = cast (round(cast((getdate()-1) as float),0,1) as datetime)

BTW: Oracle handles this easily as trunc(mydate)

Thanks in advance

Oh Using SQLServer 2005

Doug

www.cooltimbers.com

It looks to me like they will both work:

declare @.morningDt datetime set @.morningDt = '3/13/7 0:05'
declare @.afternoonDt datetime set @.afternoonDt = '3/13/7 23:59'

select cast(round(cast(@.morningDt as float),0,1) as datetime),
cast(round(cast(@.afternoonDt as float),0,1) as datetime),
round(cast(@.morningDt as float),0,1) ,
round(cast(@.afternoonDt as float),0,1)

-- -- - -
2007-03-13 00:00:00.000 2007-03-13 00:00:00.000 39152.0 39152.0

I am more used to seeing the FLOOR version.

|||

Thanks Kent for the prompt reply... and for your help in general!

I sure do wish Microsoft implements something similar to Oracles "TRUNC" function that nicely truncates to a day.

2012年2月25日星期六

Any issues with SP2 and 2005 x64?

I came across someone who mentioned in passing that there are lots of issues
with SP2 and x64, is that true? Are there any significant differences to be
aware of between SP2 on x32 vs x64?
TIA
Michael MacGregor
Database ArchitectMost of my clients run SP2 on X64 with no problem. I would rather run on SP2
than SP1.
--
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Michael MacGregor" <macnoknifespam@.noemailspam.com> wrote in message
news:Ot3z3zaFIHA.3548@.TK2MSFTNGP06.phx.gbl...
>I came across someone who mentioned in passing that there are lots of
>issues with SP2 and x64, is that true? Are there any significant
>differences to be aware of between SP2 on x32 vs x64?
> TIA
> Michael MacGregor
> Database Architect
>|||Thanks Andrew.
MTM