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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Reference Current Date in SQL Query

ptc-6292144
3-Newcomer

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.

2 REPLIES 2

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



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


Top Tags