I've made an SQL query which shows Date and Time, with Time split into Hours and Minutes.

```
select convert(varchar(10),[Date],23) as [Date], 
datepart(hour, [Time])as Hour, datepart(minute, [Time])as Minutes, 
FROM [SQLIOT].[dbo].[ZEPB_CaseLog] 

```

The table shows Hours in 24-hour format.
But I want to have it in 12-hour format instead, with single digits having a '0' prefix.

i.e: 01, 02, 03, etc.

I thought of using case to do it:

```
select convert(varchar(10),[Date],23) as [Date],
case when 
datepart(hour, [Time])> 12 then (datepart(hour, [Time])- 12) as Hour
, datepart(minute, [Time])as Minutes, 
FROM [SQLIOT].[dbo].[ZEPB_CaseLog] 

```

Doing so gives me a syntax error on line

```
datepart(hour, [Time])> 12 then (datepart(hour, [Time])- 12) as Hour

--Incorrect syntax near the keyword 'as'.

```

I'm not too familiar with doing subtractions in SQL itself. Is there anything else I should add to fix this?