2
I need a select
pull all records from the current date table (today), without entering the date, in sql-server and what the PHP syntax would look like as well. Since I have a column called Dtbase which stores the dates of the records.
2
I need a select
pull all records from the current date table (today), without entering the date, in sql-server and what the PHP syntax would look like as well. Since I have a column called Dtbase which stores the dates of the records.
1
Good morning, if I understand your question correctly you want to give a select on all table records where the date in the Dtbase field is equal to today’s, if you can enter the date,
SELECT * FROM TABELA WHERE DtBase='2016-03-14';
If you can not enter the date and always want the day can try the KURDATE() function of sqlServer, I’m not sure if it would work because it has some time working only with Oracle...
SELECT * FROM TABELA WHERE DtBase=CURDATE();
what he wants is Sql-Server.
1
Kevin,
A solution in SQL would be
select * from Tabela where convert(date, DtBase) = convert(date, getdate())
Use the function convert
for cases where time is stored near the date, then you have to do this conversion.
Now how to do in PHP do not know, because I do not work with this programming language
Right, answered what I needed just lacked php but is the least.
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."%'";
oops..., I’m so sorry
like in field date /datetime?
Yes, because depending on how the date is saved in the bank it can be in the format "2016-03-14 17:14:35". Then, using the LIKE in the date/datetime field I filter for all times of the desired date. Since it was not specified how dates were entered in the database, I gave the example using LIKE. I hope I was clear in my reply.
Browser other questions tagged php sql-server
You are not signed in. Login or sign up in order to post.
opa tentar Dtbase = GETDATE();
– Marconi
Ta, blz and in php I use this getdate(); in sql as well ?
– KevinF