Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have a field 'Hours' in sql 2005 DB of datatype varchar(50) like this :
C#
EMPCODE    HOURS

2001       10:20:00    
2001       11:10:00
2001       08:00:00
2002       05:00:00
2002       06:10:00


Now i want to add hours field empcpde wise. i want to show data through crystal report. My output shoulb be like this on crystalreport.
C#
EMPCODE    HOURS
2001       10:20:00
2001       11:10:00
2001       08:00:00
-------------------
           29:30:00
C#
2002       05:00:00
2002       06:10:00
-------------------
           11:10:00
Posted
Updated 21-Oct-13 2:41am
v2

1 solution

// Date strings are interpreted according to the current culture. 
// If the culture is en-US, this is interpreted as "January 8, 2008",
// but if the user's computer is fr-FR, this is interpreted as "August 1, 2008" 
string date = "01/08/2008";
DateTime dt = Convert.ToDateTime(date);            
Console.WriteLine("Year: {0}, Month: {1}, Day: {2}", dt.Year, dt.Month, dt.Day);

// Specify exactly how to interpret the string.
IFormatProvider culture = new System.Globalization.CultureInfo("fr-FR", true);

// Alternate choice: If the string has been input by an end user, you might  
// want to format it according to the current culture: 
// IFormatProvider culture = System.Threading.Thread.CurrentThread.CurrentCulture;
DateTime dt2 = DateTime.Parse(date, culture, System.Globalization.DateTimeStyles.AssumeLocal);
Console.WriteLine("Year: {0}, Month: {1}, Day {2}", dt2.Year, dt2.Month, dt2.Day);

/* Output (assuming first culture is en-US and second is fr-FR):
    Year: 2008, Month: 1, Day: 8
    Year: 2008, Month: 8, Day 1
 */

Reference: http://msdn.microsoft.com/en-us/library/vstudio/cc165448.aspx

Try this
 
Share this answer
 
v3
Comments
Thanks7872 21-Oct-13 8:43am    
You should put a link in your answer from where you copied the above content.

http://msdn.microsoft.com/en-us/library/vstudio/cc165448.aspx
Gitanjali Singh 21-Oct-13 8:45am    
ok
Member 8233601 22-Oct-13 4:18am    
i need it in crystalreport.please provide me any solution how to do it in crystal report

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900