My query in MS-access 2013:
Delta : DateDiff("n", [C], [D])
The error is french for "Expression syntax is invalid"
Try using the field names directly in the expression.
i.e date d reception and courriel de confirmation instead of D and C.
Related
MySQL version: 8.0.23-0ubuntu0.20.04.1 - (Ubuntu)
When running sample query:
SELECT * FROM `redacted-tbl`
WHERE `redacted-col` = 'some-invalid-date'
ORDER BY `redacted-col` DESC LIMIT 0, 25
data structure: redacted-col DATE
I'm getting #1525 - Incorrect DATE value: 'some-invalid-date' error.
Now I understand that 'some-invalid-date' is definitely not a valid mysql date format. I understand that the error is expected behavior if it's an INSERT or UPDATE query.
But why do I get such error on SELECT query? Previous version of mysql didn't throw such error for SELECT query (only for INSERT/UPDATE).
Also, how do I turn off this error for SELECT-ing DATE column? Is there any mysql flags to disable such check?
Edit (added from my comment):
In my opinion, there are good reasons to allow comparison of non-valid-date-string with DATE columns:
querying with WHERE mydatecol > '2015' to get all date that is after '2015-01-01'
even better, I can just pass user inputted date as filter (sanitized and parameter-bind-ed of course): WHERE mydatecol > ?,
if user enter 2015 then it will become shorthand for user who cares only to get all records after 2015
if user enter 2015-04, then it will become shorthand for user who want records after 2015 month 04/April)
if user enter 2015-04-15 (normal/valid mysql date string), then app will display records after 2015 month 04/April date 15
without this "non-date-validated comparison", I would have to write more application code just to check if the user inputted valid date or not, e.g.:
if the input format is 2015 then I have to change it into 2015-01-01,
else if the input format is 2015-04 then I have to change it into 2015-04-01,
else if the input format is 2015-04-15 then it's valid,
else it's not valid and throw error (or just output current date/default date or just show 'no entry matched your search criteria')
[The text of this answer was originally written by forpas https://stackoverflow.com/users/10498828/forpas ]
You can cast mydatecol to a string to perform the comparison. An easy way to do it is with CONCAT():
WHERE CONCAT(mydatecol) > '2015'
or with cast:
WHERE CAST(redacted-col AS CHAR) > 2015
I am trying to do CDC on pentaho 8.3 version Community edition, Source is Oracle and the target is Mysql.
The date format in Oracle is in the format DD-MON-YY (01-JAN-19), but when I see the data in PDI(Preview)
it appears as 2019/01/01 00:00:00.00000000.
Source query:
Select ColA, ColB
from table
where Last_upd_dt > ? and last_upd_dt <=?
in the table input step and getting the start_date and end_date from the Get System info step (Start_date as start date range, end_date as end date range) and in the Transformation Properties >> Logging>> Transformation gave a Log_table along with connections. But when I execute the transformation I am getting below errors:
Error: Unable to write the log record to log table[Log]
Error: org.pentaho.di.core.exception.KettleDatabaseException:
Error inserting/updating row
Data truncation: Incorrect datetime value: '1900-01-01 03:00:00.0' for Column Start_date' at row 1
Caused by: com.mysql.cj.jdbc.execeptions.MysqlDataTruncation:Data truncation: Incorrect datetime value: '1900-01-01 03:00:00.0' for Column Start_date' at row 1
That's because date time format problem.Place select value between input and output and define date format dd-MMM-yyyy or which is supported by output step in meta-data tab.
I'm no expert in DB Admin, I need to edit a query from Oracle to SQL in my Middleware. I am getting the error
102: Incorrect syntax near '#P0'
Can anyone help please
below is the query
<assign to="/ProcessData/WERCS/SQL">
select F_PRODUCT,
F_PRODUCT_NAME,
SUPPLIER
from T_INTERPHASE
where MODIFIED_DATE >=
TO_DATE(?,'yyyymmdd')
and AUTHGRP like '%Mining Services%'
</assign>
I have been asked to use CONVERT instead of DATE_TO - so I changed query to:
<assign to="/ProcessData/WERCS/SQL">
select F_PRODUCT,
F_PRODUCT_NAME,
SUPPLIER
from T_INTERPHASE
where MODIFIED_DATE >=
CONVERT(?,'yyyymmdd')
and AUTHGRP like '%Mining Services%'
</assign>
The MySQL function for parsing a date with a specified format is STR_TO_DATE.
<assign to="/ProcessData/WERCS/SQL">
select F_PRODUCT,
F_PRODUCT_NAME,
SUPPLIER
from T_INTERPHASE
where MODIFIED_DATE >=
STR_TO_DATE(?,'%Y%m%d')
and AUTHGRP like '%Mining Services%'
</assign>
However, the error referring to #P0 must be coming from something else.
I ran this query in DBeaver
SELECT DLY.badge_nbr,
DLY.DIM_DT_ID,attribute_type
FROM FACT_MDM_DAILY_INT DLY
WHERE SCENARIO_TYPE = 'VOLTAGE'
AND ATTRIBUTE_TYPE = 'Phase_A_Average_RMS_Voltage'
AND DLY.dim_dt_id >= TO_DATE('2016-01-28','yyyy-mm-dd');
I get the error as QUERY [VIRTUAL] [ERROR]. Interestingly when I run the same query without date comparison in WHERE clause it works fine.
SELECT DLY.badge_nbr,
DLY.DIM_DT_ID,attribute_type
FROM FACT_MDM_DAILY_INT DLY
WHERE SCENARIO_TYPE = 'VOLTAGE'
AND ATTRIBUTE_TYPE = 'Phase_A_Average_RMS_Voltage';
The to_date() function in Denodo must have at least 2 parameters:
The date format of your string field (look at java SimpleDateFormat)
The string you want to convert to a date.
Thus, your parameters appear to be transposed, and you must use a capital M for month... since lower case m means minutes.
to_date('yyyy-MM-dd','2016-01-28')
How I may be able to Trim down Time DataType when retrieving from the database?
Value from the Database : 08:00:00.0000000
What I need : 08:00:00 only
I'm SQL Server 2008, VB.Net 2010
You're not really trimming (that's removing leading or trailing spaces), but any of these should work in SQL:
SELECT CAST(#YourValue as time(0))
or
SELECT LEFT(#YourValue, 8)
or
SELECT CAST(#YourValue as char(8))