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.

@ashutoshkhantwal,

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”)

Regards,
Dominic :slight_smile:

1 Like

It wasn’t successful

@ashutoshkhantwal, Where do you find it hard ?

Regards,
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???

Regards,
Arivu

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

Regards,
Arivu

3 Likes

Hi @ashutoshkhantwal,

Please find attached sample workflow for your requirement.

Test_2.xaml (7.1 KB)

Reg,
Sarthak

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.