We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

How to display the difference of two date fields on a Base form? [closed]

asked 2019-05-13 13:37:48 +0200

tommasz gravatar image

updated 2021-05-23 01:17:30 +0200

Alex Kemp gravatar image

My HSQLDB has a pair of date fields that I'd like to use to calculate a duration to display on the input form. The form is based on a query that contains a bunch of fields including one that has a numeric calculation based on two fields. But it appears I can't do any calculations on date values in the query so I thought I'd do it on the form. The Days() function is what I want to use but so far I haven't been able to do that. If I put that in a Numerical Field's Data Value it never displays anything. I've been unable to find anything useful on this so far.

LO v6.1.5.2 Mac OS X 10.14.4

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2021-05-23 01:17:43.963785


DATEDIFF doesn't work for you in SQL?

Opaque gravatar imageOpaque ( 2019-05-13 13:58:31 +0200 )edit

It does, thanks. Everything I had googled made it look like it was specific to MS SQLServer.

tommasz gravatar imagetommasz ( 2019-05-13 14:21:59 +0200 )edit

Sorry for cutting in, what is the result of DATEDIFF for May 1, 2019 and May 2, 2019 ?

lonk gravatar imagelonk ( 2019-05-13 15:49:59 +0200 )edit

@lonk My SQL query (SELECT "Date1", "Date2", DATEDIFF( 'dd', "Date1", "Date2" ) FROM "Datum" AS "Days") calculates it to "1" - cannot show a screenshot since comments don't support upload of images; so you need to trust me ;-)

Opaque gravatar imageOpaque ( 2019-05-13 17:45:26 +0200 )edit

@Opaque Thank you so much. I'm busy learning Calc now. And in the near future, I will move forward to Base. It will be useful for me.

lonk gravatar imagelonk ( 2019-05-13 18:09:44 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-05-13 14:36:01 +0200

Opaque gravatar image

Just for the record, that there is a correct answer:

Use DATEDIFF as described in SQL FAQ

To show other users your question has been answered, click the check mark (✔) next to the answer.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-05-13 13:37:48 +0200

Seen: 144 times

Last updated: May 13 '19