You are here: Re: appending two datetimes which were converted from strings « MsSQL Server « IT news, forums, messages
Re: appending two datetimes which were converted from strings

Posted by Dan Guzman on 11/21/06 13:01

> the time is converted from string.

One method is to build a string containing both date and time in format is
'yyyymmdd hh:mm:ss'. SQL Server can then parse the string into a datetime
value. For example:

DECLARE
@MyDate datetime,
@MyTime datetime,
@MyDateTime datetime

SET @MyDate = '20061121'
SET @MyTime = '12:13:14'

--concatenate date and time strings and assign to datetime data type
SET @MyDateTime =
CONVERT(char(9), @MyDate, 112) +
CONVERT(char(8), @MyTime, 114)

--
Hope this helps.

Dan Guzman
SQL Server MVP

"paul_zaoldyeck" <niopaul@yahoo.com> wrote in message
news:1164084180.584403.64710@k70g2000cwa.googlegroups.com...
> can anyone teach me how to append to datetime data into one.
> the first is a date and the 2nd one is a time.
>
> the time is converted from string.
>
> thanks
>

 

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

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