currentDate top-level constant

Expression<DateTime> const currentDate

A sql expression that evaluates to the current date.

Depending on whether date times are stored as unix timestamps (the default) or as text on the database, this returns a unix timestamp or a string. In either case, the hour, minute and second fields will be set to null. Note that in the case where a formatted string is returned, the format will write the value in UTC.

Even if the date time stored was in a local timezone, this format returns the formatted value in UTC. For example, if your local timezone has the UTC offset +02:00 and you're inserting a (local) DateTime value at 12:34, running the hour getter on this value would return 10, since the datetime is at 10:34 in UTC.

To make this function return a value formatted as a local timestamp, you can use modify with a DateTimeModifier.localTime before invoking it, e.g.



const Expression<DateTime> currentDate = _DependingOnDateTimeExpression(
  forIsoString: _currentDateLiteral,
  forTimestamps: _DartCastExpression(
      [Constant('%s'), _currentDateLiteral],