How do I modify the statement listed below to give me the date with the time
of 12:00 AM.
declare @.Yester_day smalldatetime
set @.Yester_day = (select getdate()-1)
print @.Yester_day '
Output
2005-08-30 10:48:12.127Select DATEADD(hh,-12,CONVERT(varchar(50),getdate(),112))
--
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Joe K." wrote:
> How do I modify the statement listed below to give me the date with the ti
me
> of 12:00 AM.
>
> declare @.Yester_day smalldatetime
> set @.Yester_day = (select getdate()-1)
> print @.Yester_day '
> Output
> 2005-08-30 10:48:12.127
>
>|||DECLARE @.Yesterday SMALLDATETIME -- why the underbar?
SET @.Yesterday = DATEDIFF(DAY,1,GETDATE())
SELECT @.Yesterday
Or more elaborately:
DECLARE @.Yesterday SMALLDATETIME
SET @.Yesterday = DATEADD(DAY, -1, DATEDIFF(DAY, 0, GETDATE()))
SELECT @.Yesterday
"Joe K." <Joe K.@.discussions.microsoft.com> wrote in message
news:7F1A26A7-E861-420C-B318-4F57A6C31425@.microsoft.com...
> How do I modify the statement listed below to give me the date with the
> time
> of 12:00 AM.
>
> declare @.Yester_day smalldatetime
> set @.Yester_day = (select getdate()-1)
> print @.Yester_day '
> Output
> 2005-08-30 10:48:12.127
>
>|||declare @.Yester_day smalldatetime
set @.Yester_day = (select cast (floor(cast (getdate()-1 as float))as
datetime))
print @.Yester_day
"Joe K." wrote:
> How do I modify the statement listed below to give me the date with the ti
me
> of 12:00 AM.
>
> declare @.Yester_day smalldatetime
> set @.Yester_day = (select getdate()-1)
> print @.Yester_day '
> Output
> 2005-08-30 10:48:12.127
>
>
No comments:
Post a Comment