How to get time in 24 hour in SQL

Step 1: Write this query and specify your time, and then you will be able to get the time in 24 Hours.
example 1=> select replace(convert(char(5),cast('8:30 AM' as datetime),108),':','')--0830 
example 2=>select replace(convert(char(5),cast('02:30 PM' as datetime),108),':','') --1430
 
If you are required to get the 24 hour time from the current date in SQL, then write this SQL statement:
declare @date bigint
set @date=
SUBSTRING(replace(convert(varchar, getdate(), 114),':','')
,0,LEN(replace(convert(varchar, getdate(), 114),':',''))-4)
select @date 
 
The result would be like this:
 
 
Thanks................................... 
Ebook Download
View all
Learn
View all