Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Get previous day

Author  Topic 

fralo
Posting Yak Master

161 Posts

Posted - 2012-02-15 : 16:56:10
Hi all,

I'm trying to acquire the previous day's date and place it in variable. Is it as simple as the following, or something similar?

set @yesterday= CONVERT(varchar(8), getdate()-1, 112)

stepson
Aged Yak Warrior

545 Posts

Posted - 2012-02-16 : 01:35:43
or use

select dateadd(d,-1,getdate())
Go to Top of Page

fralo
Posting Yak Master

161 Posts

Posted - 2012-02-16 : 11:05:53
So are you saying that my code would work as well?
Go to Top of Page

stepson
Aged Yak Warrior

545 Posts

Posted - 2012-02-17 : 01:43:45
Yes ;it give you the last day in varchar data type
Go to Top of Page
   

- Advertisement -