Optional Parameters

i have query similair to this

FROM products p
WHERE p.createdAt = [[ {{dateOfCreation}} #]]CURRENT_DATE

which works when I don’t input any value for dateOfCreation parameter but when I input a value, it fails
error below

ERROR: operator does not exist: date # date Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 1219

Any help

Hi @anonymous

  1. Post “Diagnostic Info” from Admin > Troubleshooting.
  2. Which database are you querying?
  3. Post your query

For reference, not all database uses # as comment syntax: https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#default-value-in-the-query

database is postgres
query =

select * from
FROM _schedule 
where _schedule.created_at::date >= {{start_date}}  
and _schedule.created_at::date <= [[ {{end_date}} #]]CURRENT_DATE
  "browser-info": {
    "language": "en-GB",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
    "vendor": "Google Inc."
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.7+10",
    "java.vendor": "AdoptOpenJDK",
    "java.vendor.url": "https://adoptopenjdk.net/",
    "java.version": "11.0.7",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.7+10",
    "os.name": "Linux",
    "os.version": "4.4.0-87-generic",
    "user.language": "en",
    "user.timezone": "GMT"
  "metabase-info": {
    "databases": [
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "11.8 (Ubuntu 11.8-1.pgdg16.04+1)"
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.8"
    "run-mode": "prod",
    "version": {
      "date": "2020-11-16",
      "tag": "v0.37.2",
      "branch": "release-x.37.x",
      "hash": "25e5f70"
    "settings": {
      "report-timezone": null

if I get this right, meaning I will have to replace # with --, like shown below

select * from
FROM _schedule 
where _schedule.created_at::date >= {{start_date}}  
and _schedule.created_at::date <= [[ {{end_date}} --]]CURRENT_DATE

@anonymous Postgres uses -- as comment syntax:

alright thanks
so my earlier post is right yeah??

@anonymous If it works, then yes.