If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Access Query: Need to return a month name instead of number in the query results

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-20-03, 12:33
poontz13 poontz13 is offline
Registered User
 
Join Date: Nov 2003
Posts: 23
Access Query: Need to return a month name instead of number in the query results

Here's part of my code for my Access query:

SELECT [Enter Month 1 - 12] AS ["Month"], Sum(IIf([ProductName] Like 'FHA30*',1,0)) AS ["FHA 30"]
FROM Calculations2
WHERE (((Month([LockDate]))=[enter month 1 - 12]));

It works fine, but I'm wanting it to return the name of the month in the first column instead of the number that the user inputs. I have another table that simply has a column with the month number and a column with the month name so I thought I might be able to have a second select statment with somewhere with in the SELECT [Enter Month 1 - 12] AS ["Month"], part, but I don't know how to do that. I'm real slow when it comes to coding so any help is appreciated.
Reply With Quote
  #2 (permalink)  
Old 11-20-03, 12:43
iknownothing iknownothing is offline
Registered User
 
Join Date: Nov 2003
Location: Ireland
Posts: 10
I did something similar but it was to return the day name, this might be of some help:

SET SERVEROUTPUT ON;

DECLARE

v_date VARCHAR2 (15);

BEGIN

SELECT TO_CHAR(sysdate, 'day')
INTO v_date
FROM dual;

DBMS_OUTPUT.PUT_LINE('The Day Today Is: '|| v_date);

END;
.
Reply With Quote
  #3 (permalink)  
Old 11-20-03, 13:48
poontz13 poontz13 is offline
Registered User
 
Join Date: Nov 2003
Posts: 23
If I understand your code, that will return the system date. In my query, the user inputs what month they want the query to run on by inputting the month number, like 1 for January. Right now, my first SELECT statement returns whatever number they input in the first column just so when it returns the query you can use that if you put the qurey results in excel or something. I just want it to convert that number into the name January. I hope I'm explaining it correctly.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On