How to extract Hours,minutes,seconds from a date

Suppose I have a time field in excel which I need to use but the field on the webpage wants time in the separate form of hours, minutes and seconds.image.
Could anyone help regarding this.


hour - dateVariable.ToString(“HH”) if you need it in 24 Hours Format
and dateVariable.ToString(“hh”) if you need it in 12 Hours Format
minutes - dateVariable.ToString(“mm”)
seconds - dateVariable.ToString(“ss”)

Dominic :slight_smile:

1 Like

It wasn’t successful

@ashutoshkhantwal, Where do you find it hard ?

Dominic :slight_smile:

It is a dynamic data not static one, hence this won’t work.

Hi @ashutoshkhantwal,

It will work.
check before dateVariable data type must in DateTime else convert the string to datetime convert.ToDateTime(dateVariable)

use the above code.

@ashutoshkhantwal In What format you are getting the input???


The input is a generic variable, the format is HH:mm:ss.

If you are getting HH:mm:ss format then split the value using :
and get the hour,min,sec
For Example ->Generic Variable → GvDateTime (11:15:00)
create splittime variable and datatype->string
assign splittime=GvDateTime.ToString().Split(":")

Hour- >splittime(0) ---->11
Min- >splittime(1)------->15
Sec- >splittime(2)------->00

the other way is you need to convert hh:mm:ss into time then get the values.
string userInput = “15:43:13”
create TimeSpan varible ->timeval
assign timeval=TimeSpan.Parse(userInput)
timeval.hours.Tosting ->hour
timeval.Minutes.Tosting ->min
timeval.Seconds.Tosting → sec



Hi @ashutoshkhantwal,

Please find attached sample workflow for your requirement.

Test_2.xaml (7.1 KB)


Hey Arivu,Thanks this worked though I used something different in addition to this since the cell was of format custom. Had to format that to a date time variable using format value/assign activity.