Thread: [GENERAL] Date Time data types

[GENERAL] Date Time data types

From
Brahmam Eswar
Date:
What is difference between CLOCK_TIMESTAMP() and CURRENT_TIMESTAMP?

Is there any specific use case to differentiate them .
--
Thanks & Regards,
Brahmeswara Rao J.

Re: [GENERAL] Date Time data types

From
Murtuza Zabuawala
Date:
As per my knowledge,

CLOCK_TIMESTAMP value changes every time you call it even in the same transaction

BEGIN
  ...
  CLOCK_TIMESTAMP()  -- Gives 2017-11-23 15:02:27.492867+05:30
  ...
  ...
  CLOCK_TIMESTAMP()  -- Gives different time as per current clock time
  ...
END;


CURRENT_TIMESTAMP 
​is the time of ​
start of current transaction
​ and does not change in the same transaction.​


BEGIN
  ...
  CURRENT_TIMESTAMP() -- Gives 2017-11-23 15:01:40.171462+05:30
  ...
  ...
  CURRENT_TIMESTAMP() -- Gives same time as previous call
  ...
END;


​-- Murtuza​


On Thu, Nov 23, 2017 at 2:29 PM, Brahmam Eswar <brahmam1234@gmail.com> wrote:
What is difference between CLOCK_TIMESTAMP() and CURRENT_TIMESTAMP?

Is there any specific use case to differentiate them .
--
Thanks & Regards,
Brahmeswara Rao J.

Re: [GENERAL] Date Time data types

From
"Rakesh Kumar"
Date:
>What is difference between CLOCK_TIMESTAMP() and CURRENT_TIMESTAMP?
CURRENT_TIMESTAMP stays the same within the transaction. It is very useful when you
are you inserting to multiple tables and want to use the timestamp columns to chain the rows
together. 

CLOCK_TIMESTAMP is the true timestamp at that given instant. Useful for debugging
purposes. I hardly see a use of it in applications, for reasons mentioned above.