Calculated value in a query

D

Denis

I am trying to create three calculated fields which would return the day,
month and year of date field ArriveDate in a table named Booking but can't
seem to make it work.

I have tried Aday: Left([booking].[ArriveDate],2) and
Left([booking.ArriveDate],2) but I get an error message when i run the query
(Invalid bracketing of name).

Would appreciate any help in solving this (I hope) small problem.

Denis
 
B

Beetle

DatePart("d", [ArriveDate])

DatePart("m", [ArriveDate])

DatePart("yyyy", [ArriveDate])
 
K

KARL DEWEY

I get an error message when i run the query (Invalid bracketing of name).
Left([booking.ArriveDate],2) -- if you use an opening bracket for
table name you also need a closing for it. if you use an opening bracket
for field name you also need a closing for it.
Left([booking].[ArriveDate],2)

But dates are stored as a double precision number like this 39555.33 for
4/17/2008 7:56:08 AM.
You can use Day([booking.ArriveDate]), Month([booking.ArriveDate]), and
Year([booking.ArriveDate]) or Format([booking.ArriveDate],"d") for day,
Format([booking.ArriveDate],"m") for month, or
Format([booking.ArriveDate],"yyyy") for year.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top