I am using Grafana 8.3.4
In the Dashboard Settings->Variables, I am using MySQL query as the data source.
Even though the values are stored in datetime format in database, it is getting converted to unixtime in variables.
For eg: values in the database - 2022-01-20 05:39:34
Values returned by Grafana - 1642657174000
How to get the values as datetime format?
Related
What's wrong?
A new column (in Excel) was made for calculating Duration
Using formula to subtract values from 2 cells
For example: 2021-01-01 07:30 - 2021-01-01 07:00; Duration = 00:30:00
In MySQL table, I set the data type for the column as TIME, but it would return with error when importing
Error message: 'Error Code: 1292. Incorrect datetime value: '00:13:00 ' for column 'ride_length'
What I have tried:
Changing data type to DATETIME, INT, TIME -> None worked
Changing the data format to HH:MM:SS, HHMMSS, 'YYYY-MM-dd HH:MM:SS' in CSV -> None worked
Question
What kind of data type I should set in MySQL?
If it was the CSV file's problem, what kind of 'data format' I need to set?
Thank you very much
Actually, it might be easier for you to just import the two datetime values and then use TIMSTAMPDIFF inside MySQL:
SELECT TIMESTAMPDIFF(MINUTE, '2021-01-01 07:00:00', '2021-01-01 07:30:00')
-- 30
Note that because the difference is actually a computed quantity, it generally makes more sense to compute it when you select. This way, should one of the two values be updated later, you don't have to worry about maintaining the difference column.
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 am storing the data details in the database including the date and time of storing the data.
The date and time stored in the database shows 2017-08-01 15:40:38.153 but the same data get displayed in the winforms has the different time i.e. 2017-08-01 8:40 PM. Rest of the data matches to the data from the database and displayed in exact manner.
I'm sending request to the server, and storing input value like this:
request.date_from = dateTimePickerFromDate.Value.Date;
request.date_to = dateTimePickerToDate.Value.Date;
And my query in the database is
SELECT * from TableName where (CONVERT(date, Transaction_Date) >= #date_from and (CONVERT(date,Transaction_Date) <= #date_to))
order by Transaction_Date desc
I have data exported from MySQL db to XLS file.
There is Date column with integers (like below).
I want to convert the integers to SQL Server datetime type.
DateColumn
66478
69035
66478
69400
...
Maybe someone know how to convert it to SQL Server datetime format?
Since the integer values from excel are coming from a date column on MySQL, I assume these integer values are the days since 1900-01-01. A date on excel is stored as integer / sequence number:
Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.
source: https://support.office.com/en-us/article/datevalue-function-df8b07d4-7761-4a93-bc33-b7471bbff252
So you can use the following query to get the date from integer values on sql server:
SELECT DATEADD(D, int_column - 1, '19000101')
-- example
SELECT DATEADD(D, 66478 - 1, '19000101') -- 2082-01-03
I have a PHP application that stores PHP datetime to my MySQL table. I did not noticed that the php server is using wrong timezone settings, so all the date that is stored in the table is incorrect. My timezone is GMT+8 but the PHP 'date.timezone' was GMT+0, so I need to add 8 hours to all existing date value in the table.
current data:
ID,session_start,session_close,total_sale
1,2012-01-01 01:35:33,2012-01-01 09:35:33,8211.9
2,2012-01-02 01:32:31,2012-01-02 09:46:54,4323.56
3,2012-01-03 01:21:38,2012-01-03 09:32:21,8732.33
desired data:
ID,session_start,session_close,total_sale
1,2012-01-01 09:35:33,2012-01-01 17:35:33,8211.9
2,2012-01-02 09:32:31,2012-01-02 17:46:54,4323.56
3,2012-01-03 09:21:38,2012-01-03 17:32:21,8732.33
I need to fix the datetime for all the data in my mysql table (add 8 hours more to the original datetime value, to be precise).
I know this can be done by writing a simple PHP script to loop over all rows in that table and modify the datetime value as needed, but it will be fun (and cool too!) if somebody can show me this can be done in MySQL.
UPDATE tablename SET
session_start=DATE_ADD(session_start INTERVAL 8 HOUR),
session_close=DATE_ADD(session_close INTERVAL 8 HOUR)
WHERE
whatever