Convert Time Field to HH:MM:SS

Easy question for the early riser today! lol

Not sure why I’m having such problems with this, but I want to just take a simple field (ShipHead.ChangeTime), and convert it from “28189” to something legible.

I’m assuming somewhere within the calculated fields of a BAQ I can accomplish this?

Check this out.

It is two fields from PartTran called SysDate and SysTime and @hkeric.wci is using both to come up with a formatted datetime.

Stupid question…

Are these then put into a calculated field to display in a BAQ? I’m guessing I can do something similar since I can use ShipHead.ChangeDate and ShipHead.ChangeTime?

I only need the time, but whatever works I will take.

I have set up a calculated field with a Data Type of datetime and use the following calculation

convert(datetime, ((datediff(day,‘01/01/1900’ , ShipHead.ChangeDate))+(convert(decimal, ShipHead.ChangeTime)/86400)))

3 Likes

Yeah it would be in a calculated field.

1 Like

I use a quick nvarchar calculated field in the BAQ:

	CONVERT(varchar, DATEADD(ss, PartTran.SysTime, 0), 8)

Style 8 gives HH:MM:SS, while 14 or 114 gives HH:MM:SS:MMMM (milliseconds)

FYI, SysTime is seconds after midnight.

5 Likes

Thanks, Andris.

Don’t know why I had problems with doing this, but this worked on the first try.

Nice Andris, I am sure this post will be a favorite for years to come.

1 Like