Select current date [closed]

2

I need a select that pulls all records from the current date table (today), without informing the date, in the sql-server and how the syntax would look in PHP as well. Since I have a column named DtBase that stores the dates of the records.

    
asked by anonymous 14.03.2016 / 17:24

3 answers

1

Kevin,

A solution in SQL would be

select * from Tabela where convert(date, DtBase) = convert(date, getdate())

I use the convert function for cases where the time next to the date is stored, so you have to do this conversion.

Now how to do in PHP I do not know because I do not work with this programming language

    
14.03.2016 / 18:25
1

Good morning, if I understand your question well, you want to give a select in all the records of the table where the date in the DtBase field is the same as today, if you can insert the date,

SELECT * FROM TABELA WHERE DtBase='2016-03-14';

If you can not enter the date and always want the date of the day you can try the sqlServer function CURDATE (), I'm not sure if it would work because I already have some time that I only work with Oracle ...

SELECT * FROM TABELA WHERE DtBase=CURDATE();
    
14.03.2016 / 17:43
0

If the date in your database is stored in the format "2016-03-14 09:26:18" you can search directly in SQLServer with the command:

select * from TableName where DtBase like '%2016-03-14%';

In PHP something like:

$data = date("Y-m-d");
$busca = "FROM 'TableName' WHERE 'DtBase' LIKE '%".data."%'";
    
14.03.2016 / 17:58