Problem with months_between

Creating tables and queries
Post Reply
Krishna1944
Posts: 2
Joined: Mon Feb 18, 2019 5:39 am

Problem with months_between

Post by Krishna1944 »

Hello

I am having problem in months between function.

Query :- Calculate the age of student.
select stu_name,months_between(sysdate,stu_birth_date)/12 from stu_mast;

Error :- The data content could not be loaded.

Access is denied: MONTHS_BETWEEN in statement [select stu_name,months_between(sysdate,stu_birth_date)/12 from stu_mast;]

Please give me solution of this query.
OpenOffice 4.1.4 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problem with months_between

Post by Villeroy »

If this is an embedded HSQLDB, the statusbar looks like this:
Image

That database is documented here: http://www.hsqldb.org/doc/1.8/guide/ch09.html
It comes with function DATEDIFF. Try this:

Code: Select all

SELECT "stu_name", DATEDIFF( 'month', "stu_birth_date", CURRENT_DATE) from "stu_mast"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply