| dbxquery query="select 100-(COUNT(DISTINCT (week)) *100 / (DATEDIFF (DATE_FORMAT(FROM_UNIXTIME('1680559200'), '%Y%m%d') , DATE_FORMAT(FROM_UNIXTIME('1672527600'), '%Y%m%d'))/7)) from `mxone_db`.`pdt_disruptions` where DATE_FORMAT (DATE, '%Y%m%d' ) between DATE_FORMAT(FROM_UNIXTIME('1672527600'), '%Y%m%d') AND DATE_FORMAT(FROM_UNIXTIME('1680559200'), '%Y%m%d')" connection="dbuser"
select 100-(COUNT(DISTINCT (week)) *100 / (DATEDIFF (DATE_FORMAT('2023-04-03', '%Y%m%d') , DATE_FORMAT('2023-01-01', '%Y%m%d'))/7)) from pdt_disruptions
where DATE_FORMAT (DATE, '%Y%m%d' ) between DATE_FORMAT('2023-01-01', '%Y%m%d') AND DATE_FORMAT('2023-04-03', '%Y%m%d')
Hi,
Splunk DB Connect time zone conversion is explained here: https://docs.splunk.com/Documentation/DBX/3.8.0/DeployDBX/Createandmanagedatabaseconnections
You appear to be using MySQL or a derivative; MySQL support for time zones is explained here: https://dev.mysql.com/doc/refman/8.0/en/time-zone-support.html
If both MySQL and Splunk are properly configured, time zone conversion should work as expected when using native date types (not string types). If not, you can perform an explicit conversion:
DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME('680559200'), 'Etc/UTC', 'PST8PDT'), '%Y%m%d')
To compare dates, time zone conversion shouldn't be necessary:
DATEDIFF(FROM_UNIXTIME('1680559200'), FROM_UNIXTIME('1672527600'))
Hi,
Splunk DB Connect time zone conversion is explained here: https://docs.splunk.com/Documentation/DBX/3.8.0/DeployDBX/Createandmanagedatabaseconnections
You appear to be using MySQL or a derivative; MySQL support for time zones is explained here: https://dev.mysql.com/doc/refman/8.0/en/time-zone-support.html
If both MySQL and Splunk are properly configured, time zone conversion should work as expected when using native date types (not string types). If not, you can perform an explicit conversion:
DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME('680559200'), 'Etc/UTC', 'PST8PDT'), '%Y%m%d')
To compare dates, time zone conversion shouldn't be necessary:
DATEDIFF(FROM_UNIXTIME('1680559200'), FROM_UNIXTIME('1672527600'))