Simple Expression Builder Question

Access77

New member
Local time
Today, 02:12
Joined
Aug 30, 2019
Messages
4
I am creating the Access expression builder to create a field in a table, drawing from other fields in the same table.

I have an existing date field in the table that has the format dd/mm/yy.

I want to get the month from this existing date field.

The expression I am using is:

& Month([Date])

This works, but for single digit months (eg January), only return 1

I need the returned value to be 01.

Can someone please assist.
 
& Format(Month([Date]), "00")
 
& Format(Month([Date]), "00")


I am getting the error message 'The expression cannot be used in a calculated column', though I think you are close.



I have tried variations of this, but so far without success.
 
you are entering the expression in Calculated field.
try this expression:

IIf(Month([date]) & ""="","",IIf(Len(Month([date]) & "")<2,"0" & Month([date]) & "",Month([date]) & ""))
 
you are entering the expression in Calculated field.
try this expression:

IIf(Month([date]) & ""="","",IIf(Len(Month([date]) & "")<2,"0" & Month([date]) & "",Month([date]) & ""))


Thanks that did it!
 
Hi. Welcome to AWF! If it’s not too late yet, I would suggest changing the name of your field because Date is a reserved word and can be a cause of headaches later on.
 
Hi. Welcome to AWF! If it’s not too late yet, I would suggest changing the name of your field because Date is a reserved word and can be a cause of headaches later on.


Thanks, my field is not named date. I just used this in the example.
 

Users who are viewing this thread

Back
Top Bottom