title: How to filter a date-field with a swift vapor-fluent query
body: <p>To avoid multiple inserts of the same person in a database, I wrote the following function:</p>
  <pre><code>func anzahlDoubletten(_ req: Request, nname: String, vname: String, gebTag: Date) 
     async throws -&gt; Int {                                                                                 
      try await                                                                                            
          Teilnehmer.query(on: req.db)                                                                     
          .filter(\.$nname == nname)                                                                       
          .filter(\.$vname == vname)                                                                       
          .filter(\.$gebTag == gebTag)                                                                     
          .count()                                                                                         
  }
  </code></pre>
  <p>The function always returns 0, even if there are multiple records with the same surname, prename and birthday in the database.</p>
  <p>Here is the resulting sql-query:</p>
  <pre><code>[ DEBUG ] SELECT COUNT(&quot;teilnehmer&quot;.&quot;id&quot;) AS &quot;aggregate&quot; FROM &quot;teilnehmer&quot; WHERE &quot;teilnehmer&quot;.&quot;nname&quot; = $1 AND &quot;teilnehmer&quot;.&quot;vname&quot; = $2 AND &quot;teilnehmer&quot;.&quot;geburtstag&quot; = $3 [&quot;neumann&quot;, &quot;alfred e.&quot;, 1999-09-09 00:00:00 +0000] [database-id: psql, request-id: 1AC70C41-EADE-43C2-A12A-99C19462EDE3] (FluentPostgresDriver/FluentPostgresDatabase.swift:29)
  [ INFO ] anzahlDoubletten=0 [request-id: 1AC70C41-EADE-43C2-A12A-99C19462EDE3] (App/Controllers/TeilnehmerController.swift:49)
  
  </code></pre>
  <p>if I query directly I obtain:</p>
  <pre><code>lwm=# select nname, vname, geburtstag from teilnehmer;
    nname  |   vname   | geburtstag 
  ---------+-----------+------------
   neumann | alfred e. | 1999-09-09
   neumann | alfred e. | 1999-09-09
   neumann | alfred e. | 1999-09-09
   neumann | alfred e. | 1999-09-09
  
  </code></pre>
  <p>so count() should return 4 not 0:</p>
  <pre><code>lwm=# select count(*) from teilnehmer where nname = 'neumann' and vname = 'alfred e.' and geburtstag = '1999-09-09';
   count 
  -------
       4
  </code></pre>
  <p>My DateFormatter is defined like so:</p>
  <pre><code>let dateFormatter = ISO8601DateFormatter()                                                                                                                                                                 
          dateFormatter.formatOptions = [.withFullDate, .withDashSeparatorInDate]
  </code></pre>
  <p>And finally the attribute &quot;birthday&quot; in my model:</p>
  <pre><code>...
  @Field(key: &quot;geburtstag&quot;)
  var gebTag: Date
  ...
  </code></pre>
  <p>I inserted the 4 alfreds in my database using the model and fluent, passing the birthday &quot;1999-09-09&quot; as a String and fluent inserted all records correctly.</p>
  <p>But <code>.filter(\.$gebTag == gebTag)</code> seems to return constantly 'false'.</p>
  <p>Is it at all possible to use .filter() with data types other than String?</p>
  <p>And if so, what am I doing wrong?</p>
  <p>Many thanks for your help</p>
  <p>Michael</p>