read CSV and calculate time..

thejeraldo

Well-known member
Joined
Jun 9, 2009
Messages
70
Location
Philippines
Programming Experience
1-3
hey guys please help.. i need to read data from a CSV file. now i already found out how to do it. but the data that im going to pull out of the CSV is a time. and i need to DateDiff them so i can get the number of hours an employee was in the office. any help?.. thanks guys!
 
Suppose your CSV data is:

08:00,16:00

You have this in 2 variables, clockIn and clockOut

Dim dtIn as DateTime = DateTime.ParseExact("20000101" & clockIn, "yyyyMMddhh:mm", CultureInfo.CurrentCulture)
Dim dtOut as DateTime = DateTime.ParseExact("20000101" & clockOut, "yyyyMMddhh:mm", CultureInfo.CurrentCulture)

Dim ts as TimeSpan = dtOut - dtIn

Messagebox.Show("Emp worked for" & ts.TotalHours)
 

Latest posts

Back
Top