c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
SQL

How to get datetime in sql query?

| | SQL

If you run following script in this SQL Command. Itwill give you same results and no performance difference. It will return the current server time.


SELECT CURRENT_TIMESTAMP;
SELECT {fn NOW()};
SELECT getdate();

The GETDATE() function returns the current date and time from the SQL Server.


If you want to take records within a certain date range.


SYNTAX:


SELECT * FROM TABLENAME WHERE DateTime <= getdate();


SELECT * FROM post WHERE Postedon <= getdate();