Solved Extracting Month name

sbaud2003

Member
Local time
Tomorrow, 02:18
Joined
Apr 5, 2020
Messages
186
I have a query based on relation ship of two tables having common field (primary key) Called DV contain value like 11 of 04/2020, means sl no 11 of April 2020, I wanted to get the month name from DV by using formula MN: MonthName(Left(Right([DV],7),2)), but it gives error showing this DV could refer to both the table. In there any way to extract the data from this field.
 
I think we would need to see a decent sample of your data to be able to give a correct answer?
Only seeing one value doesn't tell us enough I'm afraid.
 
Refer to one of the tables.
Right(tablename.DV,7)
 
If your format is fixed at "n of mm/yyyy" then

Mnumber = MID$( DV, ( Instr$( 1, DV, "/" ) - 2 ), 2 )

I included an extra parenthesis pair simply to clarify the arguments. You could omit the parentheses that are in red if you wished. If you are not up on VBA then that MID formula says "find the slash, step back two characters, and take two characters." This is how you would use it in VBA, but it is possible to use MID in a query as well. It's just clunkier if you do.

If this format is NOT always the same, then the problem gets trickier and we would need to see samples of various contents of DV.
 

Users who are viewing this thread

Back
Top Bottom