Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using 'Format' in a query....

Status
Not open for further replies.

Rmck87

Programmer
Jul 14, 2003
182
US
This is what i want to use in a SQL Server Query:

Format([p.date_start],"mmmm")

But, it says that 'Format' is an invalid function, i have used this function in Access Queries before, and it works fine, what function do i use instead of 'Format'? ? ? anyone know? Thanks alot.

-Ryan

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
Try:

select month('2003/08/01') will return 8
select datename(month, '2003/08/01') will return August

 
I believe you'd use the convert function. What format do you want the date to show as?
 
Quote "i have used this function in Access Queries before, and it works fine" Unquote

That was in Access' version of SQL. Microsoft SQL Server uses Transact-SQL (TSQL) which is mostly the same, but there are differences as you are finding out.

Remember, not all SQL was created equal. It's like English. There's American English and the Queen's English (England).

-SQLBill

 
thanks hecktic, that worked, i was going for the 'month' format. Thanks for the help.

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
You three seem to know quite a bit about SQL Server. Can i use IIF(...) in it? or is there another format i have to use?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
IIF can't be used in T-SQL. Search BOL for the CASE statement.

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top