• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1872
  • Last Modified:

I have to convert the given value into the format " Days:HH:MM:SS " in SSRS report

I have to convert the value into    DDD:HH:MM:SS   format.

For example
  if I get the value 241 ,   I have to convert it into 10:01:00:00


 When > 24 hours, to use number of days

DDD -days
HH -Hours
MM -Minutes
SS -Seconds

How to do it in ssrs expression?!
0
Manikannan
Asked:
Manikannan
  • 7
  • 6
2 Solutions
 
sureshbabukrishCommented:
what is the value 241, is it minutes, days or hours or seconds? based upon that we should write the function
0
 
ManikannanAuthor Commented:
Suresh,
 Its minutes
0
 
sureshbabukrishCommented:
declare @mint int   /*  minutes */
set @mint = 3456

Select @mint,
Cast(@mint / 1440 as Varchar) + ':' +
Cast((@mint%1440) / 60 as Varchar) + ':' +
Cast(@mint % 60 as Varchar)
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ManikannanAuthor Commented:
Suresh,

         I asked it in the SSRS expression , not in the sql stmt.
Is it possible to add in ssrs?!
  for ex
  DATEADD("n",Parameters!NoOfMinute.Value)
0
 
sureshbabukrishCommented:
yes, same logic you use it in ssrs expression by concatenating it in a expression of a text box
0
 
ManikannanAuthor Commented:
How to do that suresh?!

Now in the textbox, i'm displaying the following,

=Last(Fields!I_TIME_ON_GPS.Value)


Can u tell me how to change the "I_TIME_ON_GPS.Value"  value into "DDD:HH:MM:SS"    format
0
 
sureshbabukrishCommented:
try this in expression


CChar(Fields!I_TIME_ON_GPS.Value/1440) + ":" + CChar((DivRem(Fields!I_TIME_ON_GPS.Value,1440))/60) + ":" + CChar(DivRem(Fields!I_TIME_ON_GPS.Value,60)) + ":00"

the ":00" in last is for seconds, as the number is in minutes, you cannot divide them into seconds
0
 
ManikannanAuthor Commented:
No Suresh,

It shows the error as "wrong number of arguments" in the following part

CChar((DivRem(Fields!I_TIME_ON_GPS.Value,1440))/60)

0
 
sureshbabukrishCommented:
Replace DivRem(Fields!I_TIME_ON_GPS.Value,1440)   to Fields!I_TIME_ON_GPS.Value Mod 1440


and



DivRem(Fields!I_TIME_ON_GPS.Value,60) to Fields!I_TIME_ON_GPS.Value Mod 60
0
 
ManikannanAuthor Commented:
Its showing error only.

Is it working in ur side?!
0
 
sureshbabukrishCommented:
it should work , try to use each part at a time and then keep on adding one by one if the earlier one works
0
 
ManikannanAuthor Commented:
I use like the following,

Fields!I_TIME_ON_GPS.Value \ 1440  & ":" & Fields!I_TIME_ON_GPS.Value \ 60 & ":" & Fields!I_TIME_ON_GPS.Value mod 60



Its working,  Thanks suresh for your idea.
0
 
ManikannanAuthor Commented:
It helped me partially
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now