0

Say I have a column

Date
23-03-2019
04-04-2019

I want to find hoe many minutes the whole month has in MySQL.

Expected output:

Date            MinsinMonth
23-03-2019       44640      
04-04-2019       43200
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
AlisonGrey
  • 497
  • 1
  • 7
  • 23

2 Answers2

3

Basically, you just want to find the number of days in the month and then do some multiplication. For this, use last_day():

select day(last_day(date)) * 24 * 60 as minutes_in_month
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
2

This should work:

SELECT DAY(LAST_DAY(Date)) * 1440 AS MinsinMonth

LAST_DAY returns the last day in the month a date is in

DAY Returns the day number associated to a date

1440 is the number of minutes per day (60 * 24)

vc 74
  • 37,131
  • 7
  • 73
  • 89