How query based on the datestamp which is a string data type in mongodb - mongodb-query

Here is the how the datastamp is in my json.I need to query based on the time stamp.
Datastamp:2016-02-10T11:43:15----string type
I tried querying by using substr which didn't work.
db.General_Liability.aggregate({$project : {new_time_stamp : {$substr : ["$session.Datestamp",0, 10]}}});
Please let me know how i should query.

I suppose you need a query for one day. You can use $gt and $lt for this.
db.General_Liability.find({ "session._Datestamp":{"$gte":ISODate("2016-02-10T00:00:00"), "$lt":ISODate("2016-02-11T00:00:00")}})

Related

Request last hour data from Big Query with Standard SQL

This is my problem.
I would like to request only the data of the last hour from Big Query.
I would like to use Standard Sql.
I would like to pay only for read the data in this interval of time.
Example :
My partition of the day take 200 Go. I request data of the last hour (40Go). Is it possible to pay only for 40Go in Standard SQL ?
Thanks !
You can use table decorators (specifically range decorators) but they are supported in BigQuery Legacy SQL ONLY
To get data from the last hour you can use below:
SELECT <list_of_fields>
FROM [yourproject:yourdataset.yourtable#-3600000-]
Of course, the preferred query syntax for BigQuery is standard SQL - so you can either have your query logic built with Legacy SQL syntax and thus have whole logic in one query or you can use split logic to first get last hour data into temp table using legacy's sql decorators and then use standard sql to apply needed logic
Meantime see below opened issue on Google's Issue Tracker:
Support an equivalent to table decorators in standard SQL
From that thread - looks like the closest feature to meet your case could be hourly partitioning - whenever it will be available

How could we use one search results in another search using sub search query?

Query :
search event_name=email OR event |where NOT LIKE(person_id,"%WF%")| stats dc(person_id)
Result :
618bd8ea-59dc-485f-a0a3-908adb804443
6618bb54-73fd-4d13-b2e2-72e18171a904
WF724ad888-cbd4-483f-91b3-01a95809ad7b
WF9e9f0ec6-899e-43a8-b1e3-ca158516b6f
I need to use this above result again in same query to get those records count which are not starting with "WF".
Please suggest .
Any help would be really appreciated.

MS Access Having Clause

Alright so I understand the point of the HAVING clause. I am having an issue and I am wondering if I can solve this the way I want to.
I want to execute one query using ADODB.Recordset and then use the Filter function to sift through the data set.
The problem is the query at the moment which looks like this:
SELECT tblMT.Folder, tblMT.MTDATE, tblMT.Cust, Sum(tblMT.Hours)
FROM tblMT
GROUP BY tblMT.Folder, tblMT.MTDATE, tblMT.Cust
HAVING tblMT.Cust LIKE "TEST*" AND Min(tblMT.MTDATE)>=Date()-30 AND MAX(tblMT.MTDATE)<=Date()
ORDER BY tblMT.TheDATE DESC;
So the above works as expected.... however I want to be able to use the tblMT.Cust as the filter without having to keep re querying the database. If I remove it I get a:
Data type mismatch in criteria expression.
Is what I am trying to do possible? If someone can point me in the right direction here would be great.
Ok... the type mismatch is caused because either tblmt.mtdate isn't a date field or tblmt.hours isn't a number field AND you have data that either isn't a date or isn't a number when the customer isn't like 'TEST*'. Or, for some customers, you have a NULL in mt.date and null can't be compared with >=. you'd still get the error if you said where tblMt.cust not like "TEST*" too.
Problem is likely with the data or your expectation and you need to handle it.
What data types are tblMT.hours and tblMt.MtDate?

Get Full Executed Query in Postgresql

Halo,
first, i say thank you for helping me solve my problem before.
I'm really newbie using Postgresql.
now i have new problem,
i do select statement like this one :
select * from company where id=10;
when i see the query in pg_stat_statements, i just get the query like this :
select * from company where id=?;
from the result the value of id is missing,
how i can get the complete query without missing the value??
Thank you :)
Alternatively you could set log_min_duration to 0 which will lead Postgres to log every statement.
Pg_stat_statements is meant to be for stats and these are aggregated, if every lookup value would be in there the stats would be useless because it would be hard to group.
If you want to understand a query just run it with explain analyze and you will get the query plan.

How compare only date with nhibernate and criteria

im trying to compare two dates like this
ICriteria criteria = base.DataStore.TransactionScope.NHibernateSession.CreateCriteria<CcCorte>();
criteria.Add(Restrictions.Ge("Start", init.Date));
But im just need to compare the dates without the time, i can take only date for server variable but dont know how to do it with the other.
Any ideas?
The following functions are available in HQL, maybe you could use them:
second(...), minute(...), hour(...), day(...), month(...), year(...)
So yea write your query using hql.
and if you think thats not helpful you can always write sql query and use sql servers DateTime functions like DateDiff etc and achieve the same...
Hope that helps.