Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Working with Dates and Times in MySQL

MySQL allows for dates and times to be entered in a "relaxed" format, and then translates those entries into a standardized format. In this lab, we will be working with the date, time, datetime, and timestamp datatypes and then show how MySQL handles each one.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 04, 2025
Duration
1h 15m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Log into the MySQL Server as the `root` User and Change to the **prod** Database

    Login to the MySQL server:

    [cloud_user@host]$ mysql -u root -p
    

    Change to the prod database:

    mysql> USE prod;
    
  2. Challenge

    Insert the List of Dates Provided in the Instructions into the `date` Column

    Run the following statement to insert the dates into the date column:

    mysql> INSERT INTO records (date) VALUES ('1989-02-23'), ('17-12-01'), ('19851210'), ('19:06:04');
    
  3. Challenge

    Insert the List of Times Provided in the Instructions into the `time` Column

    Use the following statement to insert the times into the time column:

    mysql> INSERT INTO records (time) VALUES ('12:20:45'), ('08:15'), (2247), ('11:25:08.778');
    
  4. Challenge

    Insert the List of Dates and Times Provided in the Instructions into the `datetime` Column

    Run the following command to insert the list of dates and times into the datetime column:

    mysql> INSERT INTO records (datetime) VALUES ('2015:07:13 04-22-47'), (120804100712);
    
  5. Challenge

    Insert the List of Dates and Times Provided in the Instructions into the `timestamp` Column

    Run the following command to insert the list of dates and times into the timestamp column:

    mysql> INSERT INTO records (timestamp) VALUES ('19890905071153'), ('2004;05;26 02,45,03');
    
  6. Challenge

    After Setting a Baseline Timezone of ` 00:00`, Update the Time Zone by ` 03:00` Hours and See Its Effect on the `datetime` and `timestamp` Columns

    Establish a baseline timezone:

    msyql> set time_zone = '+00:00';
    

    List the data in the records table prior to updating the timezone to +03:00:

    mysql> select * from records;
    

    Update the timezone by +03:00 hours:

    msyql> set time_zone = '+03:00';
    

    List the data in the records table and notice the change to the timestamp column:

    mysql> select * from records;
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight