Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Date Add SQL Error

$
0
0

I have a field in a table with a date. This date contains the date when a room in a hotel was last cleaned the table in full can be seen here - 

The date to be cleaned will always be three days on from when it was last cleaned so for instance if the date the rooms was last cleaned was 21/11/2013 the date for it be cleaned next should be 24/11/2013. To do this I am attempting to use the date add function. Currently I have the following code -

Dim SQL As New OleDb.OleDbCommand("SELECT RoomID,DateLastCleaned,DateAdd(day,3,DateLastCleaned) AS DateToBeCleaned FROM Tbl_Clean", connected_db)

This however results in the following error -

Error Message

I am unsure what I have done wrong though. If it helps I managed to get this to work in access as a query using the following SQL code - 

SELECT Tbl_Clean.*, DateAdd("d",+3,[DateLastCleaned]) AS DateToClean
FROM Tbl_Clean;



Viewing all articles
Browse latest Browse all 23857

Trending Articles