Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining hours and min (hh:mm)

Status
Not open for further replies.

skurkal

IS-IT--Management
Apr 6, 2005
37
US
Hi All,

I have a table with 2 integer colums

HourPart TimePart
13 15
14 30

I need to combine these into a time colum as follows

Time
13:15
14:30

Thanks for your help in advance,
sk



 
Code:
SELECT RIGHT('0' + CONVERT(CHAR(2), HourPart), 2) + ':' + RIGHT('0' + CONVERT(CHAR(2), TimePart), 2)
 


Hi,
Code:
Select TimeSerial([HourPart],[TimePart],0)...

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

[blush] I thought I was in a different forum [blush]

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The above code will leave spaces for single digit input.
Try this:
Code:
SELECT RIGHT('0' + CONVERT(VARCHAR, 2), HourPart) + ':' + RIGHT('0' + CONVERT(VARCHAR, TimePart), 2) as Time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top