Microsoft SQL Server Management Studio / Convert 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.
 
B

Bob Barrows

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
 
T

Tyro

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"


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top