|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Select time frorm smalldatetimeHow can I select the time only from a smalldatetime field ?
Field is called 'dateinitiated' Thanks in advance, Aleks See function "convert" in BOL.
Example: select convert(varchar(25), getdate(), 108) AMB Show quote "Aleks" wrote: > How can I select the time only from a smalldatetime field ? > > Field is called 'dateinitiated' > > Thanks in advance, > > Aleks > > > Thanks guys, it worked.
A Show quote "Alejandro Mesa" <AlejandroM***@discussions.microsoft.com> wrote in message news:6D3F24E0-1405-4D6D-8B3F-ACE466B79AC4@microsoft.com... > See function "convert" in BOL. > > Example: > > select convert(varchar(25), getdate(), 108) > > > AMB > > "Aleks" wrote: > >> How can I select the time only from a smalldatetime field ? >> >> Field is called 'dateinitiated' >> >> Thanks in advance, >> >> Aleks >> >> >> Aleks wrote:
> How can I select the time only from a smalldatetime field ? There is a good article in Books Online (BOL) called "Using Date and Time> > Field is called 'dateinitiated' > > Thanks in advance, > data". You should definitely look it up. The answer depends on what you want to do with the "time" extracted from the smalldatetime. if you simply want a string containing the time, then SELECT CONVERT(varchar(20),dateinitiated,108) FROM ... If you wish to perform calculations with the resulting value, then a different solution is needed. While you're in BOL reading about the CONVERT function, also look up the DATEPART, DATEADD, and other date/time functions found in the Transact-SQL Reference.. Bob Barrows -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup. |
|||||||||||||||||||||||