[MYSQL] Date du jour - 1

Date du jour - 1 [MYSQL] - SQL/NoSQL - Programmation

Marsh Posté le 16-12-2011 à 11:08:53    

Bonjour,
 
je viens de faire une requete pour mon boulot, et je butte sur une fonction dans cette requete :  
 
    SELECT RIGHT( ps_orders.id_order, 4  ) , ps_address.lastname, ps_address.address1,  '', ps_address.address2, ps_address.postcode, ps_address.city,  'FR',  '',  '', ps_address.phone_mobile,  '',  '', ps_customer.email,  '1', ps_address.firstname,  '', ps_address.phone_mobile
FROM ps_orders, ps_address, ps_customer
WHERE ps_orders.ID_address_invoice = ps_address.id_address
AND ps_address.id_customer = ps_customer.id_customer
AND ps_orders.invoice_date BETWEEN  '2011-12-15 00:00:00' AND  '2011-12-15 23:59:59'
     
 
Pour l'instant je modifie le between[b][/b] tous les jours a J-1, ca fonctionne parfaitement, mais je souhaiterai automatiser cela afin de gagner en productivité ...
 
quelqu'un aurai une idée ?
 
Merci d'avance

Reply

Marsh Posté le 16-12-2011 à 11:08:53   

Reply

Marsh Posté le 16-12-2011 à 11:14:18    

Bon, je me réponds tout seul (j'avais pas cherché en langue anglais) ... pour ceux que ca interesse :
 
SELECT RIGHT( ps_orders.id_order, 4 ) , ps_address.lastname, ps_address.address1, '', ps_address.address2, ps_address.postcode, ps_address.city, 'FR', '', '', ps_address.phone_mobile, '', '', ps_customer.email, '1', ps_address.firstname, '', ps_address.phone_mobile
FROM ps_orders, ps_address, ps_customer
WHERE ps_orders.ID_address_invoice = ps_address.id_address
AND ps_address.id_customer = ps_customer.id_customer
and ps_orders.invoice_date between DATE_SUB(CONCAT(CURDATE(), ' 00:00:00'), INTERVAL 1 DAY) and DATE_SUB(CONCAT(CURDATE(), ' 23:59:59'), INTERVAL 1 DAY)

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed