Microsoft SQL Server Management Studio / Convert Date

  • Thread starter Thread starter Tyro
  • Start date Start date
T

Tyro

This isn't exactly a Microsoft Access question, but I didn't know where else
to go. I am using Microsoft SQL Server Management Studio. The table and
field name are “dbo.EncounterData.CreateDateTime†The results are formatted
like “2010-03-02 10:36:52.527â€. Would you know how I can use the Convert
function to format the results as “yyyymmddâ€. I know it is something like
one of these:

select (convert (char(8), getdate(), 112)

SELECT CONVERT(VARCHAR(8),CONVERT(DATETIME),112)

but I can't get either one to work.
 
Tyro said:
This isn't exactly a Microsoft Access question, but I didn't know
where else to go. I am using Microsoft SQL Server Management Studio.
The table and field name are "dbo.EncounterData.CreateDateTime" The
results are formatted like "2010-03-02 10:36:52.527". Would you
know how I can use the Convert function to format the results as
"yyyymmdd". I know it is something like one of these:

select (convert (char(8), getdate(), 112)

Why did you put the parenthesis before the name of the function? The general
syntax for calling functions is
functionname(parameters)
Like this:
select convert(char(8), getdate(), 112)
SELECT CONVERT(VARCHAR(8),CONVERT(DATETIME),112)

Ughh! ;-)

The sql server version of this group is
microsoft.public.sqlserver.programming
 
Thank you Bob.
--
Tyro from Missouri


Bob Barrows said:
Why did you put the parenthesis before the name of the function? The general
syntax for calling functions is
functionname(parameters)
Like this:
select convert(char(8), getdate(), 112)


Ughh! ;-)

The sql server version of this group is
microsoft.public.sqlserver.programming

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.
 
Back
Top