Re: conversion

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 08/30/04


Date: Mon, 30 Aug 2004 09:59:24 +0200

On Mon, 30 Aug 2004 09:37:12 +0200, simon wrote:

>I have table time where I have column for second,minute and hour.
>
>For example:
>
>hour minute second
>------------------------------
> 9 5 3
>
>If I execute: SELECT cast(hour as varchar(2))+':'+cast(minute as
>varchar(2))+':'+cast(second as varchar(2)) as time FROM time, I'll get:
>
>9:5:3, but what I would like to get is: 09:05:03
>
>Is there some simple conversion or I have to use string function len and
>select case statements?
>
>thank you,
>Simon
>

Hi Simon,

You can use RIGHT('00' + CAST(hour AS varchar(2)), 2)

Best, Hugo

-- 
(Remove _NO_ and _SPAM_ to get my e-mail address)


Relevant Pages

  • Re: How to include join operator as column in outer join
    ... >If you change your code to the following (for easier viewing my changes are ... Hi Simon, ... Best, Hugo ... (Remove _NO_ and _SPAM_ to get my e-mail address) ...
    (microsoft.public.sqlserver.programming)
  • Re: Multiple variables
    ... use character type varchar - but it will cuase SQL Server to do an ... I prefer to use explicit conversion, ... Always test code suggestions on a test database. ... Best, Hugo ...
    (microsoft.public.sqlserver.mseq)
  • Re: Multiple variables
    ... "Hugo Kornelis" wrote: ... > use character type varchar - but it will cuase SQL Server to do an ... > implicit conversion under the hood. ... > Always test code suggestions on a test database. ...
    (microsoft.public.sqlserver.mseq)
  • Re: Import a 1.1 to 2.0 with change of resolution
    ... I didn't have much luck doing a conversion because the two designers are ... Regards ... Simon. ... > VGA Resolution device. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: supress activex message on open workbook
    ... in the section "Forms3 and ActiveX initialization " ... Hugo ... > Simon Lloyd ...
    (microsoft.public.excel.programming)