SQL: select date rows that contain specific hour and minute

MathMan 99

I am querying a table that has the date column as follows:

date
2021-03-08 05:05:31+00
2021-03-08 05:10:31+00

How can I select all the rows that contain 05:05 as the hour and minute in SQL? i.e. rows where hour = 05, and minute = 05. In this case it will be the first row.

paulsm4

Q: How can I select all the rows that contain 05:05 as the hour and minute in SQL?

A: For MySQL, look in the MySql Date and Time functions. There, you'll find Extract().

You can use it as follows:

https://www.w3schools.com/sql/func_mysql_extract.asp

Extract the minute from a datetime:

SELECT EXTRACT(MINUTE FROM "2017-06-15 09:34:21");

This assumes that you're storing the column as a "Date" type.

Different RDBMS vendors have different Date/Time functions. You'll have to read the documentation and experiment to determine which syntax to use for your particular DB vendor and your particular table schema.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Select rows with a specific date

Query SQL hour to minute

Where condition with a specific hour and minute from a Timestamp SQL

SQL extracting hour and minute from date into a single column

SQL group records by date/hour/minute and join table

Select all rows that contain that are at least a certain date

SQL Server : query to get MINUTE of date in specific date

Ant Design - How can I disable a specific hour/minute in a rangepicker based on the date?

How to get the date with specific hour and minute of today from "HH:mm" string in Objecive-C

SQL SELECT rows with max date

run cron every minute during a specific hour?

Windows Service run every hour in specific minute

Casting a specific hour and minute and getting the time difference

Select Date with Specific Time SQL

Insert Hour and Minute to mongoDB date in node js

Convert Time Stamp into date, time, hour, minute

Set date, day, hour, minute, second interval

In SQL: How to concat hour and minute (stored as integers in a separate column) with the date part of a timestamp?

How to select last hour and groupby minute?

Getting data after Specific date and hour, but Date and Hour are in diffferent columns in SQL Server

Select rows in Pandas which does not contain a specific character

How to select the rows that contain a specific value in at least one of the elements in a row?

How to select rows based on two column that must contain specific value?

Pandas - how to select rows which contain specific value in it

Extract the record for last hour for specific date SQL Server

Select all rows with date column equal to today's date in postgres to the minute

Round to nearest MINUTE or HOUR in Standard SQL BigQuery

How to take Average of Duration in Hour & Minute in SQL?

SQL get every hour and minute of day