• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Function as Field Name in Access

I have a query that I would like to put a function as a fieldname such as

select start_Date as Date() from table

The problem is access does not ssem to allow functions to replace field names. Is there a way of getting around this?
0
sesurb
Asked:
sesurb
  • 5
  • 4
1 Solution
 
JCinDECommented:
Okay I need clarification:

Do you want to have a field named 'start_Date' that contains today's date?

  select Date() as start_Date from table

Do you want to have a field named 'Date' that contains the value in start_date?

  select start_Date as [Date] from table

Do you want to have a field named 'Date()' that contains the value in start_date?

  select start_Date as [Date()] from table
0
 
JCinDECommented:
Above, I use [ and ] to enclose a field name that Access normally recognizes as a special keyword. The [ and ] force Access to treat it as a field name.
0
 
sesurbAuthor Commented:
The solution
select start_Date as [Date()] from table
is what I want but when I do this Access outputs the fiels as a string "date()" when I actually want it to be "10/22/2003" or whatever the current date is.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
JCinDECommented:
Okay so what you want is my first suggestion. A field named 'start_Date' containing the day's date:

  select Date() as start_Date from table

0
 
JCinDECommented:
What is in the field named 'start_Date'?

If what's in there is a string that you want to convert to a date, do this:

  select CDate(start_Date) as start_Date from table
0
 
sesurbAuthor Commented:
The field contains non-pertinent information. What is happening is that records are categorized by month and the data is already there but we need to change some column names to there corresponding month but that month changes depending on the data so if I can just get an actual dynamic date as the column header then I can manipulate to meet my needs but I am having trouble getting the date as the column header.
0
 
sesurbAuthor Commented:
And it is the last slection that I need not the first.

 select start_Date as [Date()] from table
0
 
JCinDECommented:
oh, you want today's date as the column header?

Well you can try doing a crosstab query with MonthName(Month([start_Date]),False) as a Column Heading

But otherwise, I don't know of any way to dynamically change the column heading names within a query.
0
 
sesurbAuthor Commented:
I think the crosstab query might work or at least the basic concept of the crosstab query. I will let you know the outcome
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now