I am having a problem adjusting this part of my SQL statement:
HAVING dbo.BOOKINGS.BOOKED = CONVERT(int, CONVERT(datetime,
FLOOR(CONVERT(float, GETDATE()))) + 2)
Normally, the page that uses this statement just lists the amount of sales for today, I want to switch the GETDATE() to a date that I declare. I tried all different formats and none have worked
Use the DATEADD/DATEDIFF method of setting the time portion to midnight of the current date – it’s the fastest means, and casting to FLOAT can be unreliable:
Then, you can set your own date easily if you use a variable (@var in this example, within a stored procedure or function):
This assumes @var is a DATETIME data type. Otherwise, you’ll need to use a date format SQL Server will implicitly convert to a DATETIME — or use CAST/CONVERT to explicitly convert the value.