I wanna split time field to before hour and after hour part and based on the definition of
date_trunc i am using this code:
date_trunc('hour', time_field)
input: 2022-07-31 20:00:23.000
output: 2022-07-31 19:30:00.000
Why this code changes 20:00:23.000 to 19:30:00.000.
And my second question is about toHour .I am using below code :
toHour(time_field)
input : 2022-07-31 19:30:00.000
output : 0
it should be 19 ,why 0?
and when i use:
formatDateTime(time_field, '%Y-%m-%d-%H')
input : 2015-10-18 21:40:13.000
output : 2015-10-19-01
what's the matter with these functions? do i need to convert the time to another timezone?
Thanks to my teammates this issue is resolved finally ! I am sharing the answer with the ones who have this issue. i use dbeaver. so ,it was a client side issue, I have to set use_server_time_zone in dbeaver to make it right
See https://github.com/ClickHouse/clickhouse-jdbc/issues/604.
Related
I need to set a custom date field with the value of trandate + 180 days. for example, if trandate is 21/03/2019 then the custom field value should set as 17/09/2019.
I tried doing the simple way {trandate}+180 but NaN is being shown as field value.
I found one field formula ADD_MONTHS(date, integer) but this is for adding months, while client requires is a date exact 180 days ahead of the transaction date.
Can anyone help me in doing that?
If you are using {trandate} then what you have written should work in a formuladate context so first thing is check your syntax.
Sometimes though Netsuite returns everything as strings so the next thing to try is TO_DATE({trandate}) + 180
Not sure about with SuiteFlow, but maybe this will help.
If you are using SuiteScript 1.0
var tranDate=nlapiStringToDate(trandate);
var newTranDate=nlapiAddDays(tranDate,180);
If you are using SuiteScript 2.0
var tranDate=new Date(trandate);
var newTranDate=tranDate.setDate(tranDate.getDate()+180);
How do we add days to dates in Orient db?
select sysdate()+1 from safetyplan;
It is giving same output as sysdate().
1 is not getting added. Can you help me, please?
According to Orientdb doc 2.2:
sysdate() returns the current date time. If executed with no parameters, it
returns a Date object, otherwise a string with the requested
format/timezone.
So one possible way is to convert date object to long using .asLong() method of date object.Then do the necessary addition.Convert it back to date using .asDate() method.
Example:To get a day added to current day use:
select sum(sysdate().asLong(),86400000).asDate() from safetyplan;
Note:we are adding in milliseconds and 1 day=1000*60*60*24 milliseconds
NB:Thought that this answers may help someone and sorry for answering my own question.
I'm using Symfony and Doctrine. I'd like to get the time elapsed between two timestamps. Here is a portion of my query (both a.date and q.date are type: timestamp):
$qb->select('a.date - q.date AS elapsed_time');
This gives a numerical result, but I can't tell what the units are. 9 seconds gave me 49, and 60 seconds gave me 99; I can't make sense of that.
I tried this too:
$qb->select('DATE_DIFF(a.date, q.date) AS elapsed_time');
This works, but gives the result in days. I really need minutes or seconds.
Use UNIX_TIMESTAMP instead. try this:
$qb->select('(UNIX_TIMESTAMP(a.date) - UNIX_TIMESTAMP(q.date)) AS elapsed_time');
You need to use the function DATE_FORMAT.
$qb->select(DATE_FORMAT(DATE_DIFF(a.date, q.date), '%s') AS elapsed_time);
Try this. I dont have a mysql console now, but i think it would work.
I have to make some changes in a existing mule flow with little knowledge and although I've spent some days reading online documentation and possible solutions to this, I cannot figure out why this query is failing, as I also have more dynamic queries in my flow with #[xxx] parameters. The query is as follows:
select times from user_request where
ip_address=SUBSTR(#message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS],2,INSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS], ':')-2)
and request_date=CAST(CURRENT_DATE as varchar2(8))
And the error I got is:
Message : Index: 0
(java.lang.IndexOutOfBoundsException). Payload :
{fecha_solicitud=2016-06-22, moneda=USD, client_id=RIVERA,
user_ip=127.0.0.1, request_times=0} Payload Type :
java.util.LinkedHashMap Element :
/OANDAFlow/processors/3 # oanda:oanda.xml:126 Element XML :
select times from user_requestwhere
ip_address=SUBSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS],2,INSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS],
':')-2)and request_date=CAST(CURRENT_DATE as
varchar2(8))>
Note: The transformation to varchar of the date is because the column request_date is varchar.
I've tried this query directly in the Oracle SQL developer replacing #[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]
with and example like /127.0.0.1:55406 and it worked fine so why through mule is failing???
In the first: #message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS] you are missing a [
One of the fields in your query expects a string value try to put a single quote..it would work ,
Try this
select times from user_request where
ip_address=SUBSTR('#message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]',2,'INSTR(#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]', ':')-2)
and request_date=CAST(CURRENT_DATE as varchar2(8))
im trying to make a query from the use of TempVars
im Using SQL to run the query but every time i try, it return Invalid date value
this is the line that will not work
this returns error
WHERE ((([Table].[Issue Date])>=#[TempVars]![tmpDateFrom]# And ([Table].[Issue Date])>=#[TempVars]![tmpDateTo]#));
this returns fine
WHERE ((([Table].[Issue Date])>=#10/12/12# And ([Table].[Issue Date])>=#11/12/12#));
I have checked the TempVars [tmpDateFrom] and [tmpDateTo] and they out put the date value i need.
Please help
Thank you all or the help.
due to the requirement of the database #Nicarus had the right answer this is the solution for those still wondering.
WHERE ((([Table].[Issue Date])>=[TempVars]![tmpDateFrom] And ([Table].[Issue Date])>=[TempVars]![tmpDateTo]));