© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
yumo

❔ date difference

Quick question, why is this not giving me any result on my column
resultado
resultado
?

horaInicio is nvarchar(max)
horaFim nvarchar(max)
resultado nvarchar(max)

// get the value of the "horaInicio" column
DateTime horaInicio = (DateTime)row.Cells["horaInicio"].Value;

// get the value of the "horaFim" column
DateTime horaFim = (DateTime)row.Cells["horaFim"].Value;

// calculate the duration between the two times
TimeSpan duration = horaFim - horaInicio;

// set the value of the "resultado" column to the duration in hours
row.Cells["resultado"].Value = duration.TotalHours;
// get the value of the "horaInicio" column
DateTime horaInicio = (DateTime)row.Cells["horaInicio"].Value;

// get the value of the "horaFim" column
DateTime horaFim = (DateTime)row.Cells["horaFim"].Value;

// calculate the duration between the two times
TimeSpan duration = horaFim - horaInicio;

// set the value of the "resultado" column to the duration in hours
row.Cells["resultado"].Value = duration.TotalHours;
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ difference in output
C#CC# / help
9mo ago
✅ Implementing IAsyncLifeTime difference
C#CC# / help
16mo ago
✅ MongoDB Date problem
C#CC# / help
9mo ago