Skip to main content
typo
Source Link
Erwin Brandstetter
  • 182.2k
  • 28
  • 457
  • 620

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of the current transaction.

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time.

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of current transaction.

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time.

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of the current transaction.

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time.

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

trim bits that were just my interpretation
Source Link
Erwin Brandstetter
  • 182.2k
  • 28
  • 457
  • 620

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of current transaction at input time ("early binding").

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time ("late binding").

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of current transaction at input time ("early binding").

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time ("late binding").

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of current transaction.

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time.

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

added 94 characters in body
Source Link
Erwin Brandstetter
  • 182.2k
  • 28
  • 457
  • 620

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of current transaction at input time ("early binding").

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time ("late binding").

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of current transaction at input time ("early binding").

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time ("late binding").

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

'now' (with any amount of leading and trailing spaces and brackets ({[( )]}, which is trimmed as noise) is a special date/time input constant. It evaluates to the timestamp of current transaction at input time ("early binding").

If you find this one strange, you should try SELECT 'allballs'::time; some time. :)

now() (without single quotes, and exactly one pair of trailing parentheses), on the other hand, is a function, evaluated at execution time ("late binding").

Both just happen to use the same English word, because they return the "current time". But both are very different in nature.

The difference becomes evident when you use either as column default. The first one cements the timestamp of the transaction setting the column default. The second one evaluates to the timestamp of the transaction inserting a new row dynamically. (Typically, you want the second.)

See:

Source Link
Erwin Brandstetter
  • 182.2k
  • 28
  • 457
  • 620
Loading