Using DATE_FORMAT in a select query I am migrating the custom code of d7 to d8 while doing I am using db_query in d7 where as in d8 I am using 

\Drupal::database()-&gt;select('node_field_data', 'spmw')
            -&gt;fields('spmw', ['id', 'created' =&gt; 'DATE_FORMAT(created, "%H:%i")'])-&gt;execute()-&gt;fetchObject();


I am getting error as

1054 Unknown column 'spmw.DATE_FORMATcreatedHi' in 'field list': SELECT spmw.id AS id, spmw.DATE_FORMATcreatedHi
You can try \Drupal::database()-&gt;select-&gt;addExpression().

For you, below code might be useful. 

\Drupal::database()
  -&gt;select('node_field_data', 'spmw')
  -&gt;fields('spmw', ['id'])
  -&gt;addExpression("DATE_FORMAT(created,'%H:%i')", "created")
  -&gt;execute()
  -&gt;fetchObject();