SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Issues with month() and datepart()
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MTSkibum
Starting Member

1 Posts

Posted - 12/03/2012 :  16:13:31  Show Profile  Reply with Quote
For ease of reading I am just going to post the select statement.

I have a sql that works just fine:

SELECT DISTINCT org.organization,
epi.item,
(NVL(net.xx_net_need, 0) * NVL(net.xx_conso_cost, 0)) Net_Need,
(NVL(net.proj_on_hand, 0) * NVL(net.xx_conso_cost, 0)) Projected_on_hand,
net.sales_date
FROM ..............

;


The problem is when i try to turn the date into a month or month/year.

This does not work:

SELECT DISTINCT org.organization,
epi.item,
(NVL(net.xx_net_need, 0) * NVL(net.xx_conso_cost, 0)) Net_Need,
(NVL(net.proj_on_hand, 0) * NVL(net.xx_conso_cost, 0)) Projected_on_hand,
month(net.sales_date)

This does not work either:

SELECT DISTINCT org.organization,
epi.item,
(NVL(net.xx_net_need, 0) * NVL(net.xx_conso_cost, 0)) Net_Need,
(NVL(net.proj_on_hand, 0) * NVL(net.xx_conso_cost, 0)) Projected_on_hand,
DATEPART(mm,net.sales_date)



I have verified that I am working with a date.

COLUMN_NAME	DATA_TYPE	NULLABLE		
SALES_DATE	DATE	        No		

Edited by - MTSkibum on 12/03/2012 16:19:03

robvolk
Most Valuable Yak

USA
15636 Posts

Posted - 12/03/2012 :  16:42:22  Show Profile  Visit robvolk's Homepage  Reply with Quote
NVL() is an Oracle function, SQLTeam is a Microsoft SQL Server website. There's an Oracle forum over at http://dbforums.com/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000