# `FUN_GET_DATE_DIFF_MINUTE` (function)

> 根据传入时间获取时间


- **Type:** FUNCTION
- **Returns:** `int`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `p_sStartDate` | `varchar(200)` |
| 2 | IN | `p_sEndDate` | `varchar(200)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `FUN_GET_DATE_DIFF_MINUTE`'`._

## Narrative

**Business context:** Returns the minute-length of a clock-time window (`HH:MM:SS` strings), wrapping across midnight when the end is "earlier" than the start (i.e. a night-shift break window like `23:30 → 00:30`). Used to compute break-window durations (lunch, dinner, midnight) for the production-scheduling time-arithmetic chain.

**What it does:** wraps both clock strings with today's date via `CONCAT(DATE_FORMAT(NOW(),'%Y-%m-%d'),' ', …)` and casts to datetime. If start ≤ end, returns `TIMESTAMPDIFF(MINUTE, start, end)`. Else returns the diff to `end + 1 DAY`. Coalesces NULL to 0.

**Invocation:** called by [`FUN_GET_CALCPLAN_DATE_END`](FUN_GET_CALCPLAN_DATE_END.md) (to compute the six break-window lengths), `Sp_Manufacture_SetTimeDivRow`, `Sp_Manufacture_SetTime_BB`, `Sp_Manufacture_SetTime_process`. Production-scheduling time-math chain.
