Solved

format function in the sql server 2000 view

Posted on 2004-08-16
5
12,424 Views
Last Modified: 2011-08-18
I am using Ms Access database, I have a query which gets the month and year of the date. to do so I use
Format([Date],"mm") AS [Month], Format([Date],"yyyy") AS [Year]
where date is the date in the table. Now I want to do the same in Sql server 2000 view where it does not accept the format function in the sql view.
please help me and solve my problem

thanks
0
Comment
Question by:ShakeelAhmed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 11810126
Select Month([Date]) as [Month], Year([Date]) as [Year] from MyTable

AW

0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 125 total points
ID: 11810167
SQL Server has Built-in functions to retrieve the Month and Year (and Day for that matter)value( as Numbers) of a Date field, though it is NOT a good idea to name fields (even as Aliases) as Year, Month, Day or Date - all of which are generally reserved words.

AW
0
 
LVL 9

Assisted Solution

by:paelo
paelo earned 125 total points
ID: 11810321
You can also use T-SQL's CONVERT function to convert a datetime field to several different predefined formats.  The below MSDN link documents many of these formats:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp

-Paul.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question