Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie SQL & dates question
Let say your month/year string is '071999' and is called V_DT, you could select
like so :
SELECT ...
FROM EVENT_TABLE
WHERE EVENT_DATE BETWEEN TO_DATE('01'||V_DT,'DDMMYYYY')
AND LAST_DAY(TO_DATE('01'||V_DT,'DDMMYYYY'));
Simple really.
Marc
Rich Gilmour wrote:
> Hello coders.
>
> I'm working on a web-based events calendar which allows a user to select a
> month/year, then builds a calendar for the appropriate month/year, and fills
> the day slots with any matching dates from an Oracle table containing events
> and their dates.
>
> The problem I'm currently stumped on is how to construct the SQL select
> statement. The page which displays the calendar is passed two values, month
> & year. I need to get all records in a table whose date field matches the
> dates passed from the form - basically all records for a given month and
> year. The tricky part is that the dates in the database are in the Oracle
> 12:00:00:000AM/PM format and I need to compare this against a month/year
> string....how does one do that?!?
>
> I suspect I need to do some formating in the host language rather than SQL
> (in this case Tcl --- yikes).
>
> Any insight/advice is greatly appreciated.
>
> Rich Gilmour
Received on Tue Jul 06 1999 - 15:24:21 CDT
![]() |
![]() |