I try to make a query between a stream (contains a datetime) and a store mongodb table on a datetime column.
define stream TriggerStream (lastexec string);
#info(name = 'ExtractData')
from TriggerStream as e right outer join OFFRELOG as o
on o.lastmodified> e.lastexec
select CLIC_OFFRELOG,lastmodified
insert into RECO_TEST;
I get no data from this query. Is there a way to cast datetime column in timsstamp format ?
Best regards,
Nicolas
The above query works only if the column(lastmodified) is of type long which is matched to a timestamp column of BSON type of long.
Siddhi-store-mongodb does not support date column out of the box. I have opened an issue in the Github repository to track this support.
I have been using postgreSQL. My table has 3 columns date, time and userId. I have to find out records between the given date and time frame. Since date and time columns are different, 'BETWEEN' clause is not providing valid results
Combine the two columns into a single timestamp by adding the time to the date:
select *
from some_table
where date_column + time_column
between timestamp '2017-06-14 17:30:00' and timestamp '2017-06-19 08:26:00';
Note that this will not use an index on date_column or time_column. You would need to create an index on that expression. Or better: use a single column defined as timestamp instead.
I need storage 2 colums with date_time in my postgresql DB table.
date_time date_time_human
676484556463346 09.06.2017 9:38:00
date_time - like oracle timestamp( this date in seconds)
date_time_human - date in normal form
What type of field should be?
INSERT INTO tabl (date_time, date_time_human) VALUES(now(), now())
It seems to me that if you have the same value in these fields, then there is no sense in starting it twice.
Create one field of type timestamp. And in seconds you can output and record using functions.
Data Type Formatting Functions
I have data over time for particular users and timestamp of the form 2013-11-23 16:00:00-05 - there's by minute by minute date for each user and corresponding usage value.
So the table has values: user_ID, localminute, usage.
I am trying to aggregate usage at a day wise level, what i did so far is below s but I was looking for an easier way to do it without creating the dummy column date_event:
alter table tablename add column date_event date
update table set date_event = date(localminute)
select sum(use), date_event from tablename group by date_event
My question is about how I can extract date from timestamp and aggregate in a single query. Thanks for any help!
Just cast it to a date:
select sum(use), localminute::date
from tablename
group by localminute::date;
or using standard SQL:
select sum(use), cast(localminute as date)
from tablename
group by cast(localminute as date);
I want to insert date and time in oracle database, I have created the table with columns
create table myadmin
( employe_id number(5),
supervisor Varchar2(20),
department Varchar2(20),
action Varchar2(20),
sdate date,
stime date)
While inserting the values below it gives an error. Please tell me how to insert the time ?
insert into myadmin
( employe_id,supervisor,department,action,sdate,stime) values
(83,'gaurav','helpdesk','pick','23-jan-2013','09:43:00');
You have to use keyword to_date for date insert in oracle like this.
to_date('23-01-2013','dd-mm-yyyy')
Basically you have to use keyword to_date('your date','your date format').
You can also add date and time together if you want and it would be something like this
to_date('23-01-2013 09:43:00','dd-mm-yyyy hh24:mi:ss')
A date in Oracle always has a date part and a time part. Having date and time in two separate columns only makes sense, if it can occur that date is null and time is not. (And still, you could set date to an improbable value like 1.1.0001 then.)
However, if you want to stick to those two separate fields, then make your string a datetime with the to_date function specifying the format used:
insert into myadmin
( employe_id,supervisor,department,action,sdate,stime) values
(83,'gaurav','helpdesk','pick',to_date('23-01-2013','dd-mm-yyyy'), to_date('09:43:00', 'hh24:mi:ss'));