# Convert minutes to Weeks/Days/Hours/Minutes

Hey guys,

I have a column in the SQL Server database which tells me the number of minutes between 2 dates.

Could anyone tell me how to convert that to the format;

3 Years, 2 Months, 1 Week, 2 Days, 13 Hours, 52 Minutes.

I get lost very quickly.

Cheers,

Stuart

stuartgmilton (BOB member since 2003-01-30)

Hi,

I would suggest you to create a new universe object that would calculate this for you.

However if you need a report-level solution then the conversion from the number of minutes to days, hours and minutes should use this formula:

``````=FormatNumber(Floor([number of minutes] /1440) ;"0") + " days, " +
FormatNumber(Floor(Mod([number of minutes] ;1440)/60) ;"0") + " hours, " +
FormatNumber(Mod(Mod([number of minutes] ;1440) ;60) ;"0") + " minutes"``````

It would be more complicated formula (if possible at all) for the conversion that would display also the number of months/years - the reason is the varying number of days in months. So without knowing either the start date or the end date you are not able to say whether 4000 minutes are from February to April or from March to Mayâ€¦

Marek Chladny (BOB member since 2003-11-27)

Ah ha,

Cheers, I assume â€˜Floorâ€™ only takes the â€˜whole numbersâ€™ shall we say and then you used â€˜Modâ€™, to get the remainder?

Thanks,

Stuart

stuartgmilton (BOB member since 2003-01-30)

Thatâ€™s what is used in the above formula - Floor() and Mod().

Or do you mean something else?

Marek Chladny (BOB member since 2003-11-27)

Sorry, I think I was thinking aloud.

stuartgmilton (BOB member since 2003-01-30)

OK, I got what you meant
Yes, Floor() is for getting the â€˜wholeâ€™ numbers and Mod() for the remainders.

You are welcome 8)

Marek Chladny (BOB member since 2003-11-27)

Hi

I am new crystal reportsâ€¦I have got the same problemâ€¦want to convert the days in to days:hours:minutes format.I saw your formula.But i could not understand.Please can you explain me how to use the formula in crystal reports.