You are here: Re: CONVERSION FROM CHAR(4) TO DATETIME « MsSQL Server « IT news, forums, messages
Re: CONVERSION FROM CHAR(4) TO DATETIME

Posted by paul_zaoldyeck on 11/24/06 01:58

thanks for the codes...they all worked out...
regards!!!
Hugo Kornelis wrote:
> On 22 Nov 2006 22:46:19 -0800, paul_zaoldyeck wrote:
>
> >i have another problem.and it's now on converting a char(4) to datetime
> >here is the situation
> >J_TIM < F_TIM
> >
> >J_TIM is datetime while F_TIM is char of 4
> >
> >example
> >
> >J_TIM = 20:30
> >F_TIM = 2030
> >
> >how can i convert F_TIM to datetime so that i can compare them.
> >???
> >
> >thanks
>
> Hi Paul,
>
> DECLARE @F_TIM char(4);
> SET @F_TIM = '2030';
> SELECT STUFF(@F_TIM, 3, 0, ':');
> SELECT CAST(STUFF(@F_TIM, 3, 0, ':') AS datetime);
>
> Note that the reply posted by othellomy will work, but won't enable you
> to efficiently use an index on the J_TIM column (in case there is one).
>
> Also read Tibor's ultimate guide to the datetime datatype. You'll find
> it at http://www.karaszi.com/SQLServer/info_datetime.asp
>
> --
> Hugo Kornelis, SQL Server MVP

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация