|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Select date range now -> end the month
Anyone know how I would check to see if a date was between now and the end of the month?
|
|
#2
|
|||
|
|||
|
Quote:
Code:
SELECT CASE WHEN (SYSDATE <= :D1)
AND (TO_CHAR(:D1,'MMYYYY') = TO_CHAR(SYSDATE,'MMYYYY'))
THEN 'Y' ELSE 'N'
END SAME_MONTH
FROM DUAL;
|
|
#3
|
|||
|
|||
|
:test_date between sysdate and last_day(sysdate)
works for 'whole' days last_day returns the last day in the current month, but with the current time, so it it will give an incorrect result if you run it for a date/time of say 31-jul-2004 15:30 when the system time is 11:15 If you want to be more accurate you could use :test_date >= sysdate and :test_date < last_day(trunc(sysdate))+1 |
|
#4
|
||||
|
||||
|
Thanks, didn't know about last_day.
So after seeing that, I believe what I need is: Code:
SELECT * FROM mytable WHERE myCol BETWEEN SYSDATE AND trunc(last_day(add_months(SYSDATE, 1))) Thanks! |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Select date range now -> end the month |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|