EdiSimoes Posted June 13, 2012 at 12:27 PM Report Share #462448 Posted June 13, 2012 at 12:27 PM Alguem poderia me ajudar a subtrair uma data no vb e BD sqlServer 2008. Tenho dois campos datetime, SAIDA e CHEGADA, onde são guandado a data e hora de saida / e data e hora de chegada. Agora tenho que clicar em um botão e atualizar a chegada e calcular o tempo de viagem e atualizar o terceiro campo que seria o TOTAL da viagem. Desde ja agradeço a cooperação de todos. Edi Carlos Simões Estudante de Análise e Desenvolvimento de Sistemas edisimoes@bol.com.br http://www.desenvolvenetma.com.br http://analisedesistemas.bl.ee Link to comment Share on other sites More sharing options...
petvetbr Posted June 13, 2012 at 12:59 PM Report Share #462455 Posted June 13, 2012 at 12:59 PM Aqui tem exemplo em C#,mas acho que dá para ter ideia de como fazer http://www.techrepublic.com/article/calculate-period-of-time-with-net/5760752 Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
EdiSimoes Posted June 13, 2012 at 01:07 PM Author Report Share #462458 Posted June 13, 2012 at 01:07 PM (edited) E como passo esse código para Visual Basic??? try { DateTime dt1 = DateTime.Now; DateTime dt2 = new DateTime (2003,4,15); TimeSpan ts = dt1.Subtract (dt2); Console.WriteLine (ts); } catch (Exception ex) { Console.WriteLine ( ex.Message); } Edited June 13, 2012 at 05:40 PM by ribeiro55 Edi Carlos Simões Estudante de Análise e Desenvolvimento de Sistemas edisimoes@bol.com.br http://www.desenvolvenetma.com.br http://analisedesistemas.bl.ee Link to comment Share on other sites More sharing options...
petvetbr Posted June 13, 2012 at 01:18 PM Report Share #462459 Posted June 13, 2012 at 01:18 PM (edited) achei um exemplo em VB.NET: http://stackoverflow...other-in-vb-net ou aqui: 'June 20th at 1am.>> Dim dt2 As DateTime = Convert.ToDateTime("06/20/2008 01:00:00") 'June 19th at 16:00 or 4pm.>> Dim dt1 As DateTime = Convert.ToDateTime("06/19/2008 16:00:00") 'Use a TimeSpan like this.>> Dim ts As New TimeSpan ts = dt2.Subtract(dt1) MessageBox.Show("Hours difference = " & ts.Hours.ToString) 'or use DateDiff like this.>> Dim diff As Long = DateDiff(DateInterval.Hour, dt2, dt1) MessageBox.Show("Hours difference = " & ts.Hours.ToString) Edited June 13, 2012 at 05:40 PM by ribeiro55 Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
EdiSimoes Posted June 13, 2012 at 01:51 PM Author Report Share #462488 Posted June 13, 2012 at 01:51 PM Va leu pela ajuda, muito agradecido. Deus te Abençoe Edi Carlos Simões Estudante de Análise e Desenvolvimento de Sistemas edisimoes@bol.com.br http://www.desenvolvenetma.com.br http://analisedesistemas.bl.ee Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now