Click here to Skip to main content
12,763,570 members (32,386 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 23 Jul 2010

Check Constraint to validate a Financial Year in Oracle

, 23 Jul 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Check Constraint to validate a Financial Year in Oracle
When a situation arises to check a financial year like 200910, 201011, 201112 is in correct format, here is small tip to enforce a check constraint on a column in Oracle.
FinYear int check (finyear = floor(finyear/100)*100 + ( floor(finyear/100)-(floor(finyear/10000)*100)+1))

This will ensure that the input data is a valid financial year in format like YYYYyy (200910, 201011 ...).

This can be extended to any other database or language simply replacing floor function with appropriate language specific floor function. In most of the situations, floor function is directly supported by all major languages and databases.

Happy coding...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ravi LVS
India India
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 23 Jul 2010
Article Copyright 2010 by Ravi LVS
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid