Forum Discussion
How to convert time (HH:MM:SS) into integer?
- 9 years ago
Hi Anonymous,
From the table structure provided above, I see you also have a "STARTDATE" and a"ENDATE" column, so the STARTTIME and ENDTIME could in different dates, right?
In this scenario, before using the DATEDIFF funtion, you may need to combine the start/end Date and start/end Time to start/end DateTime first. See my sample below.:smileyhappy:
Assume we have a table called "Table1" like below.
1. Use the formula below to create a calculate column called "STARTDATETIME" to combine the STARTDATE column and STARTTIME column.
STARTDATETIME = Table1[STARTDATE] + Table1[STARTTIME]
2. Use the formula below to create a calculate column called "ENDDATETIME" to combine the ENDDATE column and ENDTIME column.
ENDDATETIME = Table1[ENDDATE] + Table1[ENDTIME]
3. Then you should be able to use the formula below to calculate the duration in minutes.
DURATION = DATEDIFF(Table1[STARTDATETIME], Table1[ENDDATETIME], MINUTE)
Regards
Hello Baskar,
I want to convert HH-MM-SS into a integer as minute.
Do i have create a new measure or a new column (based on the following query) ?
create calculated column = var time = time column
var hours = left(time,2) * 3600
var Mins= mid(time,4,2) * 60
var Secs= right(time,2)
return hours + Mins + Secs
create new column . Do u want Minute level right ? so no need sec
create calculated column = var time = time column
var hours = left(time,2) * 60
var Mins= mid(time,4,2)
return hours + Mins
this is enough, try this . let me know
- Anonymous9 years agoNot applicable
Hi Baskar,
it doesn't work.
I copy pasted your formula after creating a new column. Check the error message .
- Baskar9 years agoResident Rockstar
createcalculated
this is the Formula :
column = var time = time column -- here u have to replace your time column name
var hours = left(time,2) * 60
var Mins= mid(time,4,2)
return hours + Mins
Now try