Cari Blog Ini

22 Februari 2013

How To Convert Format Datetime Become HH:MM


Apply To:
Microsoft SQL Server 2000

                                     



1. Example: Table "AbsensiHistory"


2. Run this query
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
select
cast(right('000'+cast(datepart(hour,jamin) as varchar),2) as varchar)
+ ':'
+ cast(right('000'+cast(datepart(minute,jamin) as varchar),2) as varchar) [jamin_Format_HH:MM],

cast(right('000'+cast(datepart(hour,jamout) as varchar),2) as varchar)
+ ':'
+ cast(right('000'+cast(datepart(minute,jamout) as varchar),2) as varchar) [jamout_Format_HH:MM]
from AbsensiHistory

-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------