473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

working with dates in oracle

I need to write a query in oracle 8i that will allow me to select some
rows of date within a date range. In MSSQL I would do something like
"select f1,f2 from tablea where lastdate >= '01/01/2002'" . How do I
accomplish the same type of query in Oracle.
Jul 19 '05 #1
3 26164
select f1,f2 from tablea where lastdate >=
to_date('01/01/2002','mm/dd/yyyy')
(assuming you mean month then day in your format.)
Jim

"UnixUser" <ra*********@pfshouston.com> wrote in message
news:a1**************************@posting.google.c om...
I need to write a query in oracle 8i that will allow me to select some
rows of date within a date range. In MSSQL I would do something like
"select f1,f2 from tablea where lastdate >= '01/01/2002'" . How do I
accomplish the same type of query in Oracle.

Jul 19 '05 #2

Originally posted by Kuljeet
ra*********@pfshouston.com (UnixUser) wrote in message
news:news:...
I need to write a query in oracle 8i that will allow me to

select some
rows of date within a date range. In MSSQL I would do something

like
"select f1,f2 from tablea where lastdate >= '01/01/2002'" . How

do I
accomplish the same type of query in Oracle.


try-->
select f1,f2 from tablea where to_char(lastdate,'DD/MM/YYYY') >=
'01/01/2002';

NO! See Jim Kennedy's answer for the correct approach. The above does
a string comparison, and will say that '02/01/1999' is greater than
'01/01/2002'!

--
Posted via http://dbforums.com
Jul 19 '05 #3
andrewst wrote:
Originally posted by Kuljeet
try-->
select f1,f2 from tablea where to_char(lastdate,'DD/MM/YYYY') >=
'01/01/2002';

NO! See Jim Kennedy's answer for the correct approach. The above does
a string comparison, and will say that '02/01/1999' is greater than
'01/01/2002'!


And it'll be much slower since you're applying the to_char() function
for each row in the table, instead of just applying the to_date()
function once.

Of course, the bigger problem is the accuracy, not the performance...

--
//-Walt
//
//
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
1
by: Paul Long | last post by:
Hi, I'm having a nightmare when trying to insert records into an Oracle database that contain dates. I've believe I should be using the to_date() function but I continually get the error: ...
22
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b)...
0
by: Amin Schoeib | last post by:
Hi, I am a Postgres newbie who worked until now with Oracle. Now I want to know if it is possible (when yes the how?) in Postgresql To set dynamically the Localization? For example in Oracle you...
5
by: carl.barrett | last post by:
Hi, I am writing to a text file the records in an access table that is to be loaded into an Oracle system. However, I have been told that the date fields in the records I have exported to the...
12
by: kalyson | last post by:
I am using a variable of type: DATE Our instance of Oracle has: NLS_DATE_FORMAT DD-MON-YY I select a DATE from table A into this date variable. I then insert that variable...
3
by: UnixUser | last post by:
I need to write a query in oracle 8i that will allow me to select some rows of date within a date range. In MSSQL I would do something like "select f1,f2 from tablea where lastdate >=...
11
by: lenygold via DBMonster.com | last post by:
Hi everybody! This query is supposed to count consecutive years from the current year without OLAP. Input Table: ID DateCol 1 02/01/2006 1 01/01/2006 1 01/01/2005
2
by: angi35 | last post by:
Hi, I'm working in Access 2000. I have a form with a series of date fields, showing the progress of a project from start to completion. There's a set of fields/controls for projected dates (when...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.