I have date format issue. Below is my query. Query is executing but without result.
SELECT a,b,c,DATE_FORMAT(Date_Rx_Written,'%m-%d-%Y') AS 'Date Rx Written',e,f,g,h
FROM ksclient1003.prescriber_view
WHERE DATE_FORMAT(Date_Rx_Written,'%m-%d-%Y')
BETWEEN coalesce(NULLIF('11-11-2008',' '),Date_RX_Written)
AND coalesce(NULLIF('11-11-2016',' '),Date_RX_Written)
AND a=coalesce(NULLIF('Genene Radden',' '),a)
AND b=coalesce(NULLIF('Filled',' '),b);
if i execute in parts it is working fine like,
SELECT a,b,c,DATE_FORMAT(Date_Rx_Written,'%m-%d-%Y') AS 'Date Rx Written',e,f,g,h
FROM ksclient1003.prescriber_view;
or simply excluding date filter.
SELECT a,b,c,DATE_FORMAT(Date_Rx_Written,'%m-%d-%Y') AS 'Date Rx Written',e,f,g,h
FROM ksclient1003.prescriber_view
WHERE a=coalesce(NULLIF('Genene Radden',' '),a)
AND b=coalesce(NULLIF('Filled',' '),b);
i have tried different approach like changing format every place where i am simply passing Date_RX_Written.
Note :
Try
SELECT
a, b, c,
DATE_FORMAT(Date_Rx_Written,'%m-%d-%Y') as 'Date Rx Written',
e,f,g,h
FROM ksclient1003.prescriber_view
WHERE
Date_Rx_Written BETWEEN '2008-11-11' AND '2016-11-11'
AND a='Genene Radden'
AND b='Filled';
找到了解决办法..
select a,b,c,DATE_FORMAT(Date_Rx_Written,"%m-%d-%Y") as 'Date Rx Written' ,d,e,f,g from ksclient1003.prescriber_view WHERE Date_Rx_Written BETWEEN coalesce(NULLIF(STR_TO_DATE('31-12-2014' , "%d-%m-%Y"),' ')) and coalesce(NULLIF(STR_TO_DATE('31-12-2016' , "%d-%m-%Y"),' ')) and a=coalesce(NULLIF('Genene Radden',' '),a) and b=coalesce(NULLIF('Filled',' '),b);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.