473,395 Members | 1,702 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,395 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 26171
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.