General discussion

Locked

Convert SQL Server Time - Using VB

By rsp05 ·
Hi:

I have a problem trying to convert an integer stored in SQL Server which represents a time value. I am running a system stored proc (sp_help_job), and one of the colums is 'next_run_date'. The time value is stored as, for ex., 112000, for 11:20:00.
Using the 24 hour time clock, and the all the chrs except the last two (don't need the seconds), I am able to manipulate this into a readable time format. However, 12:00 AM, is represented not by 2400, but by a 0 (zero), and 12:01 AM is 100, 12:02 AM is 200, and so on. This logic is weird, and so I was wondering if there is a conversion function or way to make it consistent for any value? Can someone please help me? TIA..

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Convert SQL Server Time - Using VB

by miket In reply to Convert SQL Server Time ...

Pad your time string on the left with zeroes to make it always be 6 characters long. That way, your function to convert the time to a readable format will always work the same:

select convert(varchar(6), replicate("0", 6 - Len('next_run_date')) + ltrim(str('next_run_date')))

Collapse -

Convert SQL Server Time - Using VB

by rsp05 In reply to Convert SQL Server Time ...

Poster rated this answer

Collapse -

Convert SQL Server Time - Using VB

by rsp05 In reply to Convert SQL Server Time ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums