PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 15, 2022

[FIXED] How to get data from database of current date

 January 15, 2022     phpmyadmin, python, sql, sql-server     No comments   

Issue

I want to get all data of current date from my database I'm using phpMyAdmin this is the query which I use but it did not show any data

SELECT * FROM tables WHERE time = CURDATE();

1


Solution

In SQL Server, you can do:

WHERE CONVERT(DATE, time) = CONVERT(DATE, time)

SQL Server is smart enough to use an index when converting a date/time to a date, so this is index-safe.

Your syntax is more reminiscent of MySQL. In that database, the best solution is:

WHERE time >= curdate() AND
      time < curdate() + interval 1 day


Answered By - Gordon Linoff
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing