Hi, I'm trying an aggregation function called $dateSubtract to get the previous months value. But the query doesn't recognize the function.
This is my query:
{
"$addFields": {
"previous_month": {
"$dateSubtract": {
"startDate": "$startTime",
"unit": "month",
"amount": 1,
"timezone": "Asia/Riyadh"
}
}
}
},
{
"$project": {
"_id": 0,
"PM": "$previous_month"
}
}
Here are the diagnostics
{
"browser-info": {
"language": "en-US",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.12+7",
"java.vendor": "Eclipse Foundation",
"java.vendor.url": "https://adoptium.net/",
"java.version": "11.0.12",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.12+7",
"os.name": "Linux",
"os.version": "4.15.0-1065-aws",
"user.language": "en",
"user.timezone": "Asia/Riyadh"
},
"metabase-info": {
"databases": [
"mongo"
],
"hosting-env": "unknown",
"application-database": "postgres",
"application-database-details": {
"database": {
"name": "PostgreSQL",
"version": "12.7"
},
"jdbc-driver": {
"name": "PostgreSQL JDBC Driver",
"version": "42.2.23"
}
},
"run-mode": "prod",
"version": {
"date": "2021-10-21",
"tag": "v0.41.1",
"branch": "release-x.41.x",
"hash": "76aa4a5"
},
"settings": {
"report-timezone": "Asia/Kuwait"
}
}
}