5

I'm no SQL Server expert, but I believe the following should work:

SELECT count(*) 
FROM Posts
WHERE CreationDate > DATE_SUB(NOW(), INTERVAL 90 DAY)

Unfortunately in Data Explorer all I get is:

'NOW' is not a recognized built-in function name.

I'm sure I'm just using completely the wrong syntax, but I can't even find any documentation for DE. Thanks for any assistance!

2

1 Answer 1

8

You're using functions that aren't available in SQL Server. You'll need to look at using DateAdd instead. You can use something like this:

SELECT count(*) 
FROM Posts
WHERE CreationDate > DateAdd(day, -90, getdate());

You can look through the SQL Server documentation on MSDN to help writing queries and to be sure that you're using the correct functions.

1
  • Thanks! Very helpful information. I'll check MSDN. Mar 30, 2016 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .