0

I'm looking for something similar to - DATEADD(day,-1,GETDATE())

To use like this - and sale.OrderDateKey >= (current DATE(without time) - 1 day)

e.g. and sale.OrderDateKey >= '2018-07-22'

Den
  • 171
  • 3
  • 5
  • 13
  • What is wrong with using the dateadd -1? – dfundako Jul 23 '18 at 13:46
  • DATEADD(day,-1,CAST(GETDATE() AS DATE)) – Cato Jul 23 '18 at 13:46
  • @DavidG The question is not duplicated, as you can see, I specify that I need date WITHOUT time and so one, yes you are right, that they are similar, but bot the same, as the "similar" answer is not answering my question. – Den Jul 23 '18 at 15:32
  • @DavidG then I found that need to use format 112, an so one...... Any way I could midufy my question to make it understandeble, and unique? – Den Jul 23 '18 at 15:33
  • @MatSnow What should I do to improve this question? – Den Jul 30 '18 at 11:48

2 Answers2

4

Use cast datetime(GETDATE()) to date

sale.OrderDateKey >=  DATEADD(day,-1,CAST(GETDATE() as date))
Stanislav Kundii
  • 2,874
  • 1
  • 11
  • 17
-1
and sale.OrderDateKey >= CONVERT(varchar(10), DATEADD(day, -1, GETDATE()), 120)
Will
  • 228
  • 1
  • 2
  • 15