-1

How come my statement is getting marked wrong? The question is:

Create a query based on the tblCustomer and tblPurchase tables that will concatenate the member’s first and last names (separated by a space) followed by the date they made a purchase. Name the concatenated field Purchase Details. Use a comma to separate the full name and date, in that order. Save your query as qryPurchaseDetails and then close the query.

My answer is:

Purchase Details: [FirstName] & " " & [LastName] & "," & [PurchaseDate]

When I run it on Access, it works fine but the grader is marking me wrong. Any assistance?

0

I'm going to assume that [PurchaseDate] has a data type of Date/Time therefore it would be more correct to convert to a string before concatenating it to other strings. It might not give an error in Access, but you're taking your chances that you'll like the date format that Access chooses.

Purchase Details: [FirstName] & " " [LastName] & "," & FormatDateTime([PurchaseDate],2)

Or

Purchase Details: [FirstName] & " " [LastName] & "," & Format([PurchaseDate],"yyyy-mm-dd")

Documentation for FormatDateTime()

Format()

  • How come you included ",2" at the end of the first line you sent? – Krilla13 Nov 7 '16 at 6:06
  • The 2 is an optional argument of the FormatDateTime() function.I recommend the linked documentation for further info. – mendosi Nov 7 '16 at 6:09
  • @Krilla13 I'm dying to know, did this answer suit your situation? – mendosi Nov 8 '16 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.