OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Complex date/time related query

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
ralf.butler@web.de
Newbie
Newbie


Joined: 14 Jun 2009
Posts: 3

PostPosted: Sun Jun 14, 2009 9:24 pm    Post subject: Complex date/time related query Reply with quote

Dear All,

I have some troubles to set up the right query in base.

I have two tables. Each tables have one column for date and another for time. In addition, table A has a further column which reflects a timespan in minutes. The content looks as follows:

Code:

tableA

idA | dateA      | timeA    | spanA
----|------------|----------|------
1   | 01/01/2009 | 13:45:00 | 78
2   | 02/01/2009 | 09:25:00 | 14
3   | 03/01/2009 | 07:55:00 | 11
4   | 06/01/2009 | 19:25:00 | 91


Code:

tableB

idB | dateB      | timeB   
----|------------|---------
1   | 01/01/2009 | 13:51:00
2   | 01/01/2009 | 14:16:00
3   | 02/01/2009 | 09:26:00
4   | 06/01/2009 | 19:46:00
5   | 08/01/2009 | 23:56:00


Now, I want to create a query which returns idA and idB where
(dateA & timeA) <= (dateB & timeB) AND
(dateA & timeA) + spanA >= (dateB & timeB)

In my example the result should be the following:
Code:

idA | idB
----|----
1   | 1
1   | 2
2   | 3
4   | 4


I've already difficulties to merge the date and time columns. Well, it works with the CONCAT function but this is really cumbersome. Is there any other method? Since this seems to be a minor problem, how to add the timespan (minutes) to a date & time?

It would be great if someone could help me to set up the right query.

Thank you very much,
Ralf
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Mon Jun 15, 2009 1:22 am    Post subject: Reply with quote

Hello

Use the function datediff
http://wiki.services.openoffice.org/wiki/Built-in_functions_and_Stored_Procedures#Date_and_Time_Functions

If possible make one column for the time and date instead of two use timestamp

Romke
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group