Languages
[Edit]
EN

MySQL - TIMESTEMP() function example

0 points
Created by:
Emrys-Li
580

In this article, we would like to show you TIMESTAMP() function example in MySQL.

Quick solution: 

TIMESTAMP(expression);

or 

TIMESTAMP(expression1, expression2);

Where:

  • expression - DATE or DATETIME value,
  • expression1 - DATE or DATETIME value,
  • expression2 -  TIME value.

Practical examples

Example 1 - DATE argument

In this example, we will display the timestamp value for the given DATE expression 2021-04-27.

Query:

SELECT TIMESTAMP('2021-04-27');

Result:

MySQL - TIMESTAMP() function result
MySQL - TIMESTAMP() function result

Example 2 - DATETIME argument

In this example, we will display the timestamp value for the given DATETIME expression 2021-04-27 19:20:00.

Query:

SELECT TIMESTAMP('2021-04-27 19:20:00');

Result:

MySQL - TIMESTAMP() function result
MySQL - TIMESTAMP() function result

Example 3 - DATE and TIME arguments

In this example, we will display the timestamp value for the given DATE and TIME expressions 2021-04-27 and 19:20:00.

Query:

SELECT TIMESTAMP('2021-04-27', '19:20:00');

Result:

MySQL - TIMESTAMP() function result
MySQL - TIMESTAMP() function result
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

MySQL - dates

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join