Jump to content
CloudPT

Datas

Recommended Posts

CloudPT

Ola eu não precebo muito bem de datas em asp lol.

Precisava de uma ajuda por exemplo duas datas 2011-05-01 a 2011-05-10 vão 9 dias

Era precisamente isto que precisava duas caixas de texto para o utilizador meter as datas e depois dar o resultado.

Alguma ajuda ?  ;)

Share this post


Link to post
Share on other sites
Tiago Salgado

Como o bruno disse, podes fazer algo como:

DateTime d1 = new DateTime(2011,05,01);
DateTime d2 = new DateTime(2011,05,10);

TimeSpan ts = d2.Subtract(d1);

Console.Write(ts.Days);

Share this post


Link to post
Share on other sites
CloudPT

Boas

Bem pessoal chegai à conclusão:

Dim data As String
        If IsDate(txt1.Text) = True And IsDate(txt2.Text) = True Then
            txt1.Text = CDate(txt1.Text)
            txt2.Text = CDate(txt2.Text)

            data = (DateTime.Parse(txt1.Text) - DateTime.Parse(txt2.Text)).ToString()
            Label1.Text = data
        End If

Obrigado

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.