how to merge multiple timetable
dear advisers, 
i have multiple timetables with different timestamps (yyyy-mm-dd hh:mm), but within a same time period.
i wish to merge multiple timetables into a single timetable, and the measurement recorded for each corresponding timestamps shall be organized in ascending order (e.g. 2020-08-01 0:00 , 2008-08-01 1:00, ....). 
thank you for your advice.
you might be able to use synchronize. if you have more than 2 tables, you will need to use it multiple times.
hey, so after some minor improvements i finally found the time to make this into a doc that everyone can use, adopt and copy. let me know what you think and if you have any improvements.

[image]

[life dashboard - the all in one tracker](https://coda.io/@heuschkelsimon/life-dashboard-all-in-one-tracker)

track your personal habits, finances, tasks and time … clock - in the same app, you can set alarms, see what hour is and count down. a simple and useful app that always is welcomed. alarm sound can be personalized. hi [@jitse\_b](/u/jitse_b)

welcome to the community !

yes you can, there are various ways to do so.

the simplest:

you may want to create a table with 3 columns,

key\_column, type text, value “k000” (or whatever you want, it doesn’t matter if you stick to only one comparison)

“material1”, type ref, source tabl… hi [@ashish.tyagi](/u/ashish.tyagi), hope below solution will work for you

assign

var\_int\_count = list\_mailmessages.where(function(x) convert.todatetime(x.date).tostring(“dd/mm/yyyy”)=date.now.tostring(“dd/mm/yyyy”)).count [@najoua.abbaci](/u/najoua.abbaci)

mabye the flow can be adopted to following:

assign:

leftside: drresult (datatype: datarow)

right side:

dt\_datepv.asenumerable.orderby(function ( r ) datetime.parseexact(r(0).tostring.trim, “dd.mm.yyyy”, system.globalization.cultureinfo.currentuiculture.datetimeformat)).last()

so… Use [UNIX\_TIMESTAMP](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions) function to convert timestamps to seconds, then subtract:



```
select UNIX_TIMESTAMP('20190102 02:14:18','yyyyMMdd HH:mm:ss') -
       UNIX_TIMESTAMP('20190102 00:01:05','yyyyMMdd HH:mm:ss');

```

Returns:


`7993` seconds. 


Difference in `'HH:mm:ss'` format:



```
select from_unixtime(UNIX_TIMESTAMP('20190102 02:14:18','yyyyMMdd HH:mm:ss') -
       UNIX_TIMESTAMP('20190102 00:01:05','yyyyMMdd HH:mm:ss'), 'HH:mm:ss');

```

Returns:



```
02:13:13

``` Please see: [How do I schedule a task to update indexes?](https://qa.mythicsoft.com/14733/how-do-i-schedule-a-task-to-update-indexes?show=14733#q14733) java.sql.timestamp is a subclass of java.util.date - it should work the same for comparison purposes:

<https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/timestamp.html>

if you specifically need a date, you could convert it back pretty easily; check if isinstance(java.sql.timestamp… let table = base.gettable("table 1")

let record = await input.recordasync("record", table)

await table.updaterecordasync(record.id, {

"single select": null

}) In the end, I found this query, which groups the way it should:  
  

```
SELECT 
 FROM_UNIXTIME( TRUNCATE( UNIX_TIMESTAMP( tstamp )/900, 0 ) * 900 ) as h,
 AVG( amount ) as v
FROM 
transactions
GROUP BY 
h
ORDER BY 
 h desc
LIMIT
 24
```