M · UDF
fnHorasEntreDatas
Lista de datas/horas de hora em hora, de Start até End.
Categoria: Data e horaTipo: UDFVersão: v1.2Fonte: Imke Feldmann, adaptado por Paulo André JesusAtualizado em: 25/09/2026
Documentação completa na Function Library →Sintaxe
fnHorasEntreDatas(Start as datetime, End as datetime) as listArgumentos
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| Start | datetime | Sim | Início. Os minutos de Start se repetem em todos os itens. |
| End | datetime | Sim | Fim, inclusive. |
Retorno
list
Código completo
let
fnHorasEntreDatas = (Start as datetime, End as datetime) as list =>
if End < Start then {}
else List.Transform(
{0 .. Number.RoundDown(Duration.TotalHours(End - Start))},
each Start + #duration(0, _, 0, 0)
),
Documentacao = [
Documentation.Name = "fnHorasEntreDatas",
Documentation.Description = "Lista de datas/horas de hora em hora entre Start e End.",
Documentation.LongDescription = "Começa em Start e soma uma hora por item enquanto não passar de End (inclusive). End anterior a Start retorna lista vazia.",
Documentation.Category = "Data e hora",
Documentation.Source = "https://github.com/ImkeF/M",
Documentation.Author = "Imke Feldmann, adaptado por Paulo André Jesus",
Documentation.Version = "1.2",
Documentation.Examples = {
[Description = "Das 1:00 às 4:29", Code = "fnHorasEntreDatas(#datetime(2018, 7, 8, 1, 0, 0), #datetime(2018, 7, 8, 4, 29, 0))",
Result = "{#datetime(2018, 7, 8, 1, 0, 0), #datetime(2018, 7, 8, 2, 0, 0), #datetime(2018, 7, 8, 3, 0, 0), #datetime(2018, 7, 8, 4, 0, 0)}"],
[Description = "24 horas exatas: 25 itens, inclui o fim", Code = "fnHorasEntreDatas(#datetime(2025, 2, 1, 0, 0, 0), #datetime(2025, 2, 2, 0, 0, 0))",
Result = "{#datetime(2025, 2, 1, 0, 0, 0), ..., #datetime(2025, 2, 2, 0, 0, 0)}"]
}
]
in
Value.ReplaceType(fnHorasEntreDatas, Value.ReplaceMetadata(Value.Type(fnHorasEntreDatas), Documentacao))Exemplos
fnHorasEntreDatas(#datetime(2018, 7, 8, 1, 0, 0), #datetime(2018, 7, 8, 4, 29, 0))
// {1:00, 2:00, 3:00, 4:00} de 08/07/2018
fnHorasEntreDatas(#datetime(2025, 2, 1, 0, 0, 0), #datetime(2025, 2, 2, 0, 0, 0))
// 25 itens: inclui 00:00 do dia seguinteDicas e observações
💡 End anterior a Start retorna lista vazia.