Subtract a day directly from CURRENT_DATE [closed]

0

I'm using a framework that allows me to set the current date as the default value, but now I need to always show the date to yesterday, the code snippet as the value set is this:

$editor = new DateTimeEdit('datacadastro_edit', false, 'd-m-Y');
$editColumn = new CustomEditColumn('Data Cadastro', 'DataCadastro', $editor, $this->dataset);
$editColumn->SetReadOnly(true);
$editColumn->SetAllowSetToNull(true);
$editColumn->SetInsertDefaultValue($this->RenderText('%CURRENT_DATE%'));
$this->ApplyCommonColumnEditProperties($editColumn);
$grid->AddInsertColumn($editColumn);

What I tried to do was this:

$editColumn->SetInsertDefaultValue($this->RenderText('%CURRENT_DATE%'.' - 1 days'));

But the date displayed is today, I'm not exactly sure if this is the right way to do it.

    
asked by anonymous 24.08.2017 / 19:30

2 answers

1

In MYSQL, all of these work:

SELECT
 CAST(current_date()-1 as date),
 Date(current_date()-1),
 DATE(CURRENT_DATE - INTERVAL 1 DAY)

    
25.08.2017 / 00:08
1

This is not looking like a native class or some heavily known lib, however, how did you use the mysql tag if a column in a SELECT :

SELECT CURRENT_DATE - INTERVAL 1 DAY

If it is to return only the results of "yesterday":

SELECT colunas FROM tabela WHERE DATE(coluna_de_data) = DATE(CURRENT_DATE - INTERVAL 1 DAY);

No INSERT :

INSERT INTO tabela (coluna1, coluna2, colunadedata)
VALUES ('valor1', 'valor2', CURRENT_DATE - INTERVAL 1 DAY)

No UPDATE :

UPDATE tabela
SET coluna1='valor1', column2='valor2', colunadedata=CURRENT_DATE - INTERVAL 1 DAY
WHERE <condição para edição(ões)>
    
24.08.2017 / 19:39