Date type in Xdata Criteriaresult

If have xdata service which return Tlist
and I get data like this.

  result :=  om.Find<Tpurchaseorder>.createalias('supplier','s').SetProjections(
  tprojections.ProjectionList //
  .add(tprojections.sum('amount').as_('amount')) //
  .Add(Linq[''] = supplierid).listvalues;

works fine except date is numeric, not date type

  "value": [
      "amount": 0,
      "date": 42109
      "amount": 1596.2344,
      "date": 42110

order_date property is Tdatetime and field in DB is Date

That's current by design: EConvertToJsonError Timestamp Column - #2 by wlandgraf.

1 Like

What's wrong here

  result := om.Find< Tpurchaseorder >.SetProjections( tprojections.ProjectionList //
    .add( tprojections.sum( 'amount' ).as_( 'amount' ) ) //
    .add( tprojections.Group( 'order_date' ).as_( 'date' ) ) ) //
    .add( TProjections.Sql<string>('convert(tilauspvm, VARCHAR(10)) ').As_('correctdate') ) // <-- compilere error here
    .add( Linq.sql( 'a.toimittaja = ''' + supplierid + #39 ) ) //

I get compiler error
E2010 Incompatible types: 'TCustomCriterion' and 'TAliasedProjection'

This line:

   .add( tprojections.Group( 'order_date' ).as_( 'date' ) ) ) //

has an extra close parenthesis, thus the projection list is over and the next .add actually refers to adding a condition, not a projection.

1 Like

thanks again.
Those empty comments at the end of line are making detecting much harder.
I wish there would be another way to tell delphi formatter not to combine this line... but that matter is out of this forums scope :slight_smile:

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.