DATEDIFF() not working in sql queries
Not a Problem
I am trying to execute the following query:
mb.runSQLQuery(`
SELECT "locationEdgeList.fromLocation.locationName","locationEdgeList.fromLocation.locationName", (DATEDIFF(Hour,"locationEdgeList.etd","locationEdgeList.eta") FROM vesselSchedule
group by "locationEdgeList.fromLocation.locationName","locationEdgeList.fromLocation.locationName"
`)
and its showing the following exception.
{
"message" : "Unrecognized expression '$DATEDIFF'",
"ok" : 0,
"code" : 168,
"codeName" : "InvalidPipelineOperator",
"name" : "MongoError"
}
Can you let me know how to make this work.
The field "locationEdgeList" is an array, to run SQLQuery against the collection, you have to unwind this field first.
In version 5.0, runSQLQuery can run as a pipeline stage so that you can write
But version 4.0 has no such feature, and you have to write it using an aggregate statement.
The field "locationEdgeList" is an array, to run SQLQuery against the collection, you have to unwind this field first.
In version 5.0, runSQLQuery can run as a pipeline stage so that you can write
But version 4.0 has no such feature, and you have to write it using an aggregate statement.
NoSQLBooster only supports MongoDB date operator as SQL Function, does not support DATEDIFF function.
The $subtracts operator subtracts two numbers to return the difference, or two dates to return the difference in milliseconds, or a date and a number in milliseconds to return the resulting date. NoSQLBooster will map "-" operation as $subtract.
You can write:
NoSQLBooster only supports MongoDB date operator as SQL Function, does not support DATEDIFF function.
The $subtracts operator subtracts two numbers to return the difference, or two dates to return the difference in milliseconds, or a date and a number in milliseconds to return the resulting date. NoSQLBooster will map "-" operation as $subtract.
You can write:
Replies have been locked on this page!