Date and Time Functions in MySQL (20 Most Important Functions)

preview_player
Показать описание
In this video we will discuss date , time and extract functions in MySQL . These functions are used day in day out in your job.

script:
CREATE TABLE date_functions_demo (
id INT ,
start_date DATE,
end_date DATE,
created_at TIMESTAMP,
updated_at TIMESTAMP,
system_date varchar(10)
);

INSERT INTO date_functions_demo (id,start_date, end_date, created_at, updated_at,system_date) VALUES
(1,'2024-01-01', '2024-12-31', '2024-01-01 10:00:00', '2024-12-31 23:59:59','12/30/2024'),
(2,'2023-06-15', '2024-06-15', '2023-06-15 08:30:00', '2024-06-15 17:45:00','08/15/2024'),
(3,'2022-05-20', '2023-05-20', '2022-05-20 12:15:00', '2023-05-20 18:00:00','10/21/2024');

Zero to hero(Advance) SQL Aggregation:

Most Asked Join Based Interview Question:

Solving 4 Trick SQL problems:

Data Analyst Spotify Case Study:

Top 10 SQL interview Questions:

Interview Question based on FULL OUTER JOIN:

Playlist to master SQL :

Rank, Dense_Rank and Row_Number:

#sql #datetime #sqlfunctions
Рекомендации по теме
Комментарии
Автор

Superb video @Ankit - I use to use these functions but the way you explained the 'WHY' behind each function is amazing.

I must say - you are an great teacher!!!

ravi
Автор

MS-SQL is superb, Please post more video related to MS-SQL OR I would suggest to create separate playlist for MySQL tutorials

sz
Автор

@4:46 I am seeing 10, 000 days as difference.

arjundev
Автор

Yes Sir, please make same videos for SQL SERVER

pateldh
Автор

Please make a video for MS SQL server too

tanmaypandey
Автор

Hi Ankit, Please make any podcast or any career transition video from sales representative, customer service to Data Analytics. If we need to show fake experience in Analytics ?...How can we get salary as per Data Analytics market standards in that case?

rajanbhatia
Автор

Hello sir,
I want to suggest you one things, You make a indian sql practice software namaste sql so can you also work on make a software where
peoples can do power practice question related to dax and all

hairavyadav
Автор

Hello Ankit, thanks for usefull content! How to add 1 hour and 30 seconds to first date?

alexeypiletskiy
Автор

(end_date - start_date) this will not give proper result if the actual difference in dates is greater than 365, since it treats dates as numbers and then subtracts!

ShivamSingh-kuxy
Автор

select str_to_date("12/24/2024", '%m/%d/%y') this query will print the date as 2020-12-24 because %y will only take first 2 digits, how to resolve this to get output as 2024-12-24.

kunaljain-ll
Автор

In MySQL, directly subtracting end_date from start_date does not generate the correct number of days because dates are treated as numerical values in the format YYYYMMDD. When you subtract these values, the result is not a meaningful day count but rather a difference in the numerical representation of the dates.

For example, consider the dates 2024-12-31 and 2024-12-26:

2024-12-31 is treated as 20241231
2024-12-26 is treated as 20241226
Subtracting these values:

20241231 - 20241226 = 5

This result is coincidentally correct in this case, but it doesn’t always work. For dates like 2024-02-20 and 2024-06-15:

2024-06-15 is treated as 20240615
2024-02-20 is treated as 20240220
Subtracting these values:

20240615 - 20240220 = 395

This result is incorrect because it doesn’t account for the actual number of days between the dates.

Source: GPT

abb_raj
Автор

I am from B.E (E&E) background passed out in 2019 with having total exp of 3.5 years and in which I have 1.7 years of experience in backend development.

I have discontinued my job due to medical emergency in last year feb(currently 1.6 years of employment gap) and now I am currently unemployed

I want to restart my career into data domain is it possible to get job in it??

user
Автор

How to create a table of date_function_demo

zahidalam
Автор

Hi Ankit I want to talk to you, how can it be possible

gyanranjan
Автор

LAST_DAY() function not working in MYSQL

dillipmandal
welcome to shbcf.ru