?
Solved

Decrement last characters of a string

Posted on 2012-08-29
3
Medium Priority
?
623 Views
Last Modified: 2012-08-29
I have a string like this: "2012-13". I want to reduce the last characters on each side of the hyphen by 1 so that it becomes 2011-12. The string represents the current payment year and is stored in a setup table. I want to be able to write a query that will allow me to enter in the criteria row payments recorded for the current payment year and the prior payment year. ie, 2012-13 and 2011-12. Can anyone provide a solution for this that I could use?
0
Comment
Question by:dinmatt
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 38345113
Use this expression:

LastPeriod: Val([CurrentPeriod])-1 & -(Val([CurrentPeriod])-2000)

/gustav
0
 

Author Closing Comment

by:dinmatt
ID: 38345129
Thank you gustav, that works perfectly and is easy to implement!
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 38345205
You are welcome!

/gustav
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question