7/04/2012

Examples of converting Excel formulas to Access 2003/XP/2000/97

Question: In Access 2003/XP/2000/97, I'm trying to build an expression that will do the same as the following Excel formula with the result formatted as "dd/mm/yyyy".
=VALUE(DATE(VALUE(MID(A1,4,1))+2000,1,1))+VALUE(MID(A1,5,3))-1
How can I do this?
Answer: In an Access query, the equivalent formula would be:


Format(DateSerial(Val(Mid([Field1],4,1))+2000,1,1)+Val(Mid([Field1],5,3))-1,"dd/mm/yyyy")
This formula uses the Format, DateSerial, Val, and Mid functions in Access. We've also replaced the reference to cell A1 with Field1.

No comments:

Post a Comment