Last active
April 18, 2024 03:37
-
-
Save YurePereira/a80671516e5a88f45fe37e1121738941 to your computer and use it in GitHub Desktop.
Podemos pegar o intervalo entre duas datas usando a estrutura TimeSpan, ela representa um intervalo de tempo no C#.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
// Definindo as datas: | |
DateTime data1 = new DateTime(2024, 1, 1, 1, 1, 1); | |
DateTime data2 = DateTime.Now; | |
// Pegando o intervalo entre duas datas: | |
TimeSpan intervalo = data2 - data1; | |
Console.WriteLine("{0} - {1} = {2} dias", | |
data2, data1, intervalo.Days); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment