Recentemente conversando com alguns desenvolvedores em um cliente, eles estavam precisando saber como calcular uma idade no SQL Server.
Fiz alguns testes e encontrei uma forma para calcular e aqui abaixo vou deixar para vocês.
DECLARE @DataNascimento DATETIME = '1991-12-12' DECLARE @Hoje DATETIME = '2016-12-11 21:00:00' -- exemplo de horário da função GETDATE() -- funciona corretamente se alterado acima para hora 00:00:00 SELECT FLOOR(DATEDIFF(DAY, @DataNascimento, @Hoje) / 365.25) -- retorna 24, idade correta SELECT DATEDIFF(HOUR, @DataNascimento, @Hoje) / 8766 -- retorna 25 incorreta
Grande abraço!
Port video games have actually long been a popular type of entertainment, providing exhilarating gameplay…
When it pertains to online gambling, safety needs to be a top issue for every…
There are many reasons to play no-cost online casino games in the coming year. The…
On the internet casinos have acquired tremendous appeal in recent times, offering gamers with the…
Welcome to our useful post concerning the very best casino site game! Whether you're a…
The random number generator (or RNG) is the program that generates the outcome of every…