Convert Integer value into Hour value (AM / PM) in SQL Server -


i have table hour values. need convert hour value am/pm format, shown here:

val   hour  ---------------  9     9:00 19     7:00 pm 10    10:00 19     7:00 pm 14     2:00 pm 

i have tried logic:

declare @timing varchar(5)='15:02'  declare @time time=cast(@timing time) select convert(varchar(50),@time, 100) 

but requires val converted varchar. there other way or inbuilt function available in sql server this?

select format(dateadd(hh,val,'00:00:00'),'hh:mm tt')  yourtable 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -