cancel
Showing results for 
Search instead for 
Did you mean: 
Community_Admin
Community Team Member
Community Team Member
Often times, we want to analyze data with the date from yesterday. How do we auto-populate yesterday's date? There are a few formats that we can use!
 
The syntax below lets us get yesterday's date with timestamp:
select dateadd(day,-1,getdate()) 

 

Community_Admin_0-1635241370626.png 
To only get yesterday's date at 00:00:00: 
select dateadd(day,-1,trunc(getdate()))

 

Community_Admin_1-1635241380771.png 
If you wish to get the date and ditch the timestamp completely, you can use the SQL formatter!
select  [dateadd(day,-1,getdate()):date]
 Community_Admin_2-1635241389789.png
you can also use the interval syntax for a more elegant code:

select [getdate():date] - interval '1 day'
Community_Admin_3-1635241396834.png
Version history
Last update:
‎10-26-2021 02:43 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Need additional support?:

Community Support Request