Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello

I want to build a sql select statment in which i can get the date before today that means today is 20 june 2012, i have to get the date as 19 june 2012. But with this i want to get other columns as well please help me with this code.

Please help
Thanks
Posted

SQL
SELECT GetDate()-1 AS Yesterday, Field2, Field3
FROM table1
 
Share this answer
 
Comments
Manas Bhardwaj 20-Jun-12 8:20am    
correct +5!
Here is one, please give it a try

SQL
Select dateadd(d,-1,GETDATE()) 


Regards
Sebastian
 
Share this answer
 
For example:
MyTable:
ID    ... BigInt
Title ... NvarChar(50)
Date  ... DateTime


Query:
SQL
Select  ID,
        Title,
        (select [Date]
            Where [Date]>='2012-06-20') as Date
from MyTable
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900