'Now' is not a recognized built-in function name

My use:
SELECT DISTINCT SO_NO “SO_NO”
FROM [PBarTOBSchedule].[dbo].[tblActivity]
WHERE DateTime.DifferenceInDays(COMPLETE_BY, Now()) < 5

Your documentation (https://help.novacuraflow.com/development/flowscript/functions/date-functions-1/now)
says that the use of Now() should result in a date. It does not. It shows the error in the topic title instead.

Hi,

looks like you are using a machine step with a db connector (ms sql db by the looks of it). So, in there, flow functions are not recognized.
You could try to assign the value of Now() to a variable first in an assignement step before the machine step
( NowVariable = {Now()} )
and then use that variable in your sql select
( …WHERE DateTime.DifferenceInDays(COMPLETE_BY, @NowVariable) < 5 )

Hope this helps!

B R
Ivan

1 Like

That worked for the Now(), but it is not recognizing DateTime module.

Error:
‘Cannot find either column “DateTime” or the user-defined function or aggregate “DateTime.Differenceindays”, or the name is ambiguous.’

Hi,

i did think that DateTime.DiferenceInDays looked a bit…pythony :slight_smile:

If you are selecting from an MS SQL db then try
datediff(day,COMPLETE_BY,@NowVariable) < 5

But also then you dont realy need Flows Now() ,you can just use SQLs GetDate()
datediff(day,COMPLETE_BY,GetDate()) < 5

B R
Ivan

Exactly as Ivan says.

But also another a small note, be careful when you include the db name in the machine step as I suspect you do here:
image

If you are in a test environment (both SQL and Flow) and you subscribe to the workflow in prod with a hard coded db name, the data will still try to write to that database (which might be your test database).

It is probably better to let the connector decide database if that makes sense.

1 Like