Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATEPART Translation from MS SQL Server

Status
Not open for further replies.

maxbld

Programmer
Nov 30, 2001
8
IT
Hi to everybody,

I'm a newbie to oracle and I've to recreate a query under this new (for me) environment. The query asks for valid results in a specified time related set of intervals into a year, by using the Datepart function:

SELECT *
FROM "Results"
WHERE ID_Measurementplace = 258 AND DATEPART([dw],
ResultTimeStamp) >= 2 AND DATEPART([dw],
ResultTimeStamp) < 7 AND ((DATEPART([hh], resulttimestamp)
= 9 AND DATEPART([n], resulttimestamp) >= 15) OR
DATEPART([hh], resulttimestamp) = 10 OR
(DATEPART([hh], resulttimestamp) = 11 AND DATEPART([n],
resulttimestamp) = 0) OR
(DATEPART([hh], resulttimestamp) = 17 AND DATEPART([n],
resulttimestamp) >= 15) OR
DATEPART([hh], resulttimestamp) = 18 OR
(DATEPART([hh], resulttimestamp) = 19 AND DATEPART([n],
resulttimestamp) = 0)) AND
ResultTimeStamp > '2002-11-01 00:00:00' AND
ResultTimeStamp <= '2002-12-01 00:00:00'
ORDER BY ResultTimeStamp

As far as I've tried, the query won't work under Oracle, and I still cannot figure out a equivalent of datepart under Oracle. Any suggestion would be *so* appreciated.

Tank you in advance.
Max.
 
The simelar results may be obtained by using to_char(<date>,<mask>) function, i.e.

DATEPART([hh], resulttimestamp)

is the same as

to_char(resulttimestamp, 'hh')

You may also need to convert it by to_number, if you need comparisons other then equality. Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top