Search code examples
ms-access-2010calculated-fielddatepart

Use DatePart() function on calculated field Access 2010


Okay so I would like to create a calculated field in access to automatically create an invoice number in the format that my company is already using.

The format is MM/YY-Group Number

I already have a field with the group number in it, and another field that has a date in the format of m/d/yyyy

I would like to pull the two digit month and the two digit year from the date field in the calculated field. I know I could use the DatePart function, but for whatever reason that function doesn't seem to work in a calculated field expression.

If anybody has any ideas of how I could accomplish this I would appreciate it.


Solution

  • Something like this should work:

    Right("0" & Month([DateField]),2) & "/" & Right(Year([DateField]),2) & "-" & [GroupNumber]