Home » SQL & PL/SQL » SQL & PL/SQL » date compare
date compare [message #242704] Mon, 04 June 2007 14:14 Go to next message
yog_23
Messages: 79
Registered: March 2007
Member
Why is this not working. Thank you.

SELECT
	COUNT(*)
FROM
	SCHEMA.MEMBER_INFO 
WHERE
	EVENT_CD = 'LICS' AND  
	TO_TIMESTAMP(TERM_DT,'MM/DD/YYYY') = '12/31/2007'


Error : Not a valid month .
Re: date compare [message #242705 is a reply to message #242704] Mon, 04 June 2007 14:16 Go to previous messageGo to next message
BlackSwan
Messages: 25035
Registered: January 2009
Location: SoCal
Senior Member
'12/31/2007' is NOT a DATE is is a STRING!
'I am a slow learner' is a STRING.
Strings are enclosed by single quote marks.
When you want a DATE use the TO_DATE function.
Re: date compare [message #242707 is a reply to message #242704] Mon, 04 June 2007 14:35 Go to previous messageGo to next message
yog_23
Messages: 79
Registered: March 2007
Member
This doesn't work either ?

SELECT
	COUNT(*)
FROM
	SCHEMA.MEMBER_INFO 
WHERE
	EVENT_CD = 'LICS' AND  
	TO_TIMESTAMP(TERM_DT,'MM/DD/YYYY') = TO_TIMESTAMP('12/31/2007','MM/DD/YYYY')
Re: date compare [message #242710 is a reply to message #242704] Mon, 04 June 2007 14:39 Go to previous message
BlackSwan
Messages: 25035
Registered: January 2009
Location: SoCal
Senior Member
>This doesn't work either ?
My car does NOT work. Tell me how to fix it.
Rhetorical question #1 - where in my post is "TO_TIMESTAMP" mentioned?
Rhetorical question #2 - What data type is "TERM_DT"?
Rhetorical question #3 - What &*^&^%&^$ error message are you getting?????????????????
Previous Topic: WHY IT'S NOT
Next Topic: database
Goto Forum:
  


Current Time: Sat Dec 03 16:10:47 CST 2016

Total time taken to generate the page: 0.08066 seconds