damodar
damodar

Reputation: 9

Show minutes to HH MM SS format in linq

I am getting a value from database in minutes(75) using LINQ. Now I want to convert this minutes into HH MM SS format using LINQ. Can any one please help me.

Thank you. I tried with the following code, but I was unsuccessful.

TimeSpan tsMinutes;
try
{    
   using (VodafoneDataClassesDataContext vodafoneDataClassesDataContext = new VodafoneDataClassesDataContext())
   {
        vodafoneDataClassesDataContext.Connection.ConnectionString = BECommon.VodafoneConnectionString;
        return (from auditFormsFilledMasters in vodafoneDataClassesDataContext.AuditFormsFilledMasters
        join storeMasters in vodafoneDataClassesDataContext.StoreMasters 
             on auditFormsFilledMasters.StoreId equals storeMasters.Id
        join deskMasters in vodafoneDataClassesDataContext.DeskMasters 
             on auditFormsFilledMasters.DeskId equals deskMasters.Id
        join usersMasters in vodafoneDataClassesDataContext.UserMasters 
             on auditFormsFilledMasters.AuditorId equals usersMasters.Id into tempMaster
        from TempCircleStore in tempMaster.DefaultIfEmpty()
        where auditFormsFilledMasters.StoreId == fieldStoreId
        select new BEAuditFormsFilledMaster
        {
            minutesSpan =  new TimeSpan(0, Convert.ToInt32(auditFormsFilledMasters.LengthofRecordinMin.ToString()), 0),
            tsMinutes = new TimeSpan(0, Convert.ToInt32(auditFormsFilledMasters.LengthofRecordinMin.ToString()), 0),
            LengthofConversation = auditFormsFilledMasters.LengthofRecordinMin.ToString(),
            where auditFormsFilledValues.AuditFormsFilledMasterId == auditFormsFilledMasters.Id
            select auditFormsFilledValues.SelectedScore).Sum(),
        }).ToList<BEAuditFormsFilledMaster>().AsReadOnly();
 }

Upvotes: 0

Views: 2306

Answers (1)

It&#39;sNotALie.
It&#39;sNotALie.

Reputation: 22794

What you need to do is use the TimeSpan.FromMinutes function, and the overloaded ToString function:

TimeSpan.FromMinutes(theAmountOfMinutes).ToString(@"hh\:mm\:ss:")

Upvotes: 4

Related Questions