Run the command and now ()

DataContext.ExecuteCommand("DELETE from Table WHERE Date < Now()");

I get a message that Now () is not a recognized built-in function name.

+3
source share
5 answers

When sending a SQL query directly to SQL Server, you need to use SQL Server functions, not .NET.

Use this instead:

DataContext.ExecuteCommand("DELETE from Table WHERE Date < GETDATE()");

GETDATE() - T-SQL equivalent for Now ()

+7
source

Now () is not TSQL. Use GETDATE () or GETUTCDATE ()

+4
source

GetDate() Now()?

+2

GETDATE() NOW()

+1

, Now() SQL.

+1

Source: https://habr.com/ru/post/1748164/


All Articles