Skip to main content
1-Visitor
January 3, 2014
Question

Reference Current Date in SQL Query

  • January 3, 2014
  • 2 replies
  • 1747 views

Hello,

I'm trying to reference the current date when having a SQL query perform. I have my service setup as a SQL (Query) and I have the following code.

Select Result, Result_On from Tests where Var_Id = '20903' ORDER BY Result_On DESC

I'm looking to have the query only pull results where Result_On is equal to the current date (today's date), however I can't seem to figure out how to make the query reference the current date.

Any help would be greatly appreciated.

2 replies

5-Regular Member
January 3, 2014

Hi Michael,

Depending on your database, there may be built-in date functions available. For example, MySQL has NOW(), CURDATE() and CURTIME(). Here's a reference for MySQL: http://www.w3schools.com/sql/sql_dates.asp


I would imagine most databases provide this functionality.


Thanks,

Adam



1-Visitor
January 3, 2014

Thanks Adam for the help! I was able to find out in order to reference the current time in a SQL(query) service inside a thing you have to refer to it as CURRENT_TIMESTAMP.