Format of Time and Adding in perspective

Hi connection.

image
I have start Time and end Time like shift wise so, I have used the numeric field. for the start and end time so need to calculate duration. But i am not sure to get the correct format. of time like I need only hours and minutes. I need to entry the **start and end time Manual. I need format of of time in hours and minutes. After that need to display the End Time - Start Time in the duration last column

Thank you.

I'm not exaclty following what you are asking, but you'll most likely need to set the start and end times to labels and add a format transform.

You'll also probably want to look at these system functions
system.date.minutesBetween()
system.date.parse()
system.date.format()
https://docs.inductiveautomation.com/display/DOC81/System+Functions

1 Like

Hi @dkhayes117

I need to enter the shift timing. Manual From Scada
image
this what exactly look like in vision. same has I need to do it in perspective.

Quite difficult to understand which component need to use un perspective.

Getting doubts on what format I need to use. for entering manual, form the ignition in HH=hours & MM=minutes. It's shouldn't exceed more than 24hours Start Time or End Time. Per shift 8hrs. but some time alternative shift will reduce or exceed their time. Duration will be calculated by the
expression like end time - minus start time

This can be accomplished using dateTimeInputs for the start and end time and a label for the duration:
You can either keep the arrows or hide them
image

setup for dateTimeInputs:
image
To hide the spinner arrows just set the style of the component to: { "overflow": "hidden" }
image
Note: you need to make the dateTimeInput small enough vertically for the overflow:hidden prop to hide the arrows

here's the expression I'm using for the duration label:

if(
	{../startDate.props.value} > {../endDate.props.value}, // date spans into next day
	stringFormat("%02d:%02d",
		hoursBetween({../startDate.props.value}, addDays({../endDate.props.value}, 1)),
		minutesBetween({../startDate.props.value}, addDays({../endDate.props.value}, 1)) % 60
	),
	stringFormat("%02d:%02d",
		hoursBetween({../startDate.props.value}, {../endDate.props.value}),
		minutesBetween({../startDate.props.value}, {../endDate.props.value}) % 60
	)
)

Credit goes to Paul for the duration calculation:

3 Likes

Thank you!! @Matthew.gaitan.

How can I get only hour? from that start time and end time. need to use in other expression.


This is use in vision from start time and end time. In this expression ET= End time & ST= Start Time.

same I need in perspective using above perspective components. Help me out to create this.expression
image

In expression I need to only hours for calculation.

You should just be able to delete the minutes portion from the final expression and have the format string be %02d:00

1 Like