SQL Variable current date - 1 day

I have a variable that retrieves the current date.

select
  dateformat(getdate(), 'yyyy-mm-dd hh:nn:ss.SSSSSS')

What i want to do is change this so it inserts the current date - 1 day.

Does anyone know the best way around this?

Thanks

Answers


I suspect you want DATEADD:

select dateformat(dateadd(dd, -1, getdate()), 'yyyy-mm-dd hh:nn:ss.SSSSSS')

Need Your Help

Ruby mechanize post with header

ruby xmlhttprequest mechanize

I have page with js that post data via XMLHttpRequest and server side script check for this header, how to send this header?

pyspark and HDFS commands

python apache-spark hdfs pyspark

I would like to do some cleanup at the start of my Spark program (Pyspark). For example, I would like to delete data from previous HDFS run. In pig this can be done using commands such as