Function as Field Name in Access

sesurb
sesurb used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
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

Commented:
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.

Author

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.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Commented:
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

Commented:
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

Author

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.

Author

Commented:
And it is the last slection that I need not the first.

 select start_Date as [Date()] from table
Commented:
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.

Author

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial