cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Reference Current Date in SQL Query

Visitor

Reference Current Date in SQL Query

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.

Tags (1)
2 REPLIES 2

Reference Current Date in SQL Query

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



Reference Current Date in SQL Query

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.

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________