473,884 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retreiving Date/Time from a Date field in Oracle database

5 New Member
I am trying to retreive a string in this format dd-MM-yyyy hh:mm:ss a from Oracle database from the column of type Date which has value 10/09/2007 07:11:16

Date strfinaldate = new java.util.Date( rs.getTimestamp (10).getDate()+ rs.getTimestamp (10).getTime()) ;

SimpleDateForma t sf = new SimpleDateForma t ("dd-MM-yyyy hh:mm:ss a");
String formatteddate = sf.format(strfi naldate );

But I am getting the o/p as 10-09-2007 12:00:00 am

Please tell me how do I get the exact date/time

Thanks
Sep 20 '07 #1
9 9764
r035198x
13,262 MVP
I am trying to retreive a string in this format dd-MM-yyyy hh:mm:ss a from Oracle database from the column of type Date which has value 10/09/2007 07:11:16

Date strfinaldate = new java.util.Date( rs.getTimestamp (10).getDate()+ rs.getTimestamp (10).getTime()) ;

SimpleDateForma t sf = new SimpleDateForma t ("dd-MM-yyyy hh:mm:ss a");
String formatteddate = sf.format(strfi naldate );

But I am getting the o/p as 10-09-2007 12:00:00 am

Please tell me how do I get the exact date/time

Thanks
You can pass a Timestamp to the format method of the SimpleDateForma t class. Try that and see if you get the correct thing.
Sep 20 '07 #2
renisha
5 New Member
I tried doing with passing the timestamp object but still getting the same o/p.
Also I tried to print this value :

String cal = ""+tsdate.getHo urs()+tsdate.ge tMinutes()+tsda te.getSeconds() ;
where tsdate is the timestamp object.

Its showing as 000

Can anyone tell me why I getting this output though in databse it is showing as
Sep 20 '07 #3
r035198x
13,262 MVP
I tried doing with passing the timestamp object but still getting the same o/p.
Also I tried to print this value :

String cal = ""+tsdate.getHo urs()+tsdate.ge tMinutes()+tsda te.getSeconds() ;
where tsdate is the timestamp object.

Its showing as 000

Can anyone tell me why I getting this output though in databse it is showing as
If the column data type is Date, then you should be using rs.getDate to extract the date.
Sep 20 '07 #4
renisha
5 New Member
If the column data type is Date, then you should be using rs.getDate to extract the date.
I have even tried this way -
Date strfinaldate =rs.getDate(10) ;

SimpleDateForma t sf = new SimpleDateForma t ("dd-MM-yyyy hh:mm:ss a");
String formatteddate = sf.format(strfi naldate );


But still getting the same o/p as before
Sep 20 '07 #5
r035198x
13,262 MVP
I have even tried this way -
Date strfinaldate =rs.getDate(10) ;

SimpleDateForma t sf = new SimpleDateForma t ("dd-MM-yyyy hh:mm:ss a");
String formatteddate = sf.format(strfi naldate );


But still getting the same o/p as before
Did you try to retrieve the date using overloaded getDate method that takes a Calendar as well?
Perhaps your driver is returning the wrong date then
Sep 20 '07 #6
r035198x
13,262 MVP
Just thought about it a bit more.
You have an Oracle Date column that's storing both date and time.
You want to retrieve both the date and time fields.

So in your sql that retrieves the date, cast the Date to Timestamp using Oracle's TO_TIMESTAMP function then use rs.getTimeStamp to get both the date and time values. Tell us how that goes.
Sep 20 '07 #7
renisha
5 New Member
Just thought about it a bit more.
You have an Oracle Date column that's storing both date and time.
You want to retrieve both the date and time fields.

So in your sql that retrieves the date, cast the Date to Timestamp using Oracle's TO_TIMESTAMP function then use rs.getTimeStamp to get both the date and time values. Tell us how that goes.

Thanks a lot !!! I tried with oracle's to_char function in the query .
I could then get the exact value .
Sep 20 '07 #8
r035198x
13,262 MVP
Thanks a lot !!! I tried with oracle's to_char function in the query .
I could then get the exact value .
So the TO_TIMESTAMP function didn't work but the TO_CHAR function worked?
Sep 20 '07 #9
renisha
5 New Member
So the TO_TIMESTAMP function didn't work but the TO_CHAR function worked?
I didn't try with TO_TIMESTAMP .
Sep 20 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
25884
by: Ric | last post by:
I am using crystal reports to attempt to extract information from this database but I need to know which records were last updated. I have managed to find a field in Oracle and its value is based on a trigger function as shown below begin select TIMESTAMP_SEQ.nextval into :new.NURS_TIMESTAMP from dual; end;
1
1123
by: Schorschi | last post by:
Is there a better way to get the date/time from VB .NET into an Access MDB than "#" & Now & "#"? I have a standard date/time field in a table in a MDB file. And the '#' trick works, but seems rather hoaky.
7
4246
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in a "yyyyMMdd" format? (difference between Express and MSDE2000A ?) What is the one and only true way to deal with this problem in VB2005: Local settings are Dutch (Belgium) ; thus date is in "dd/MM/yy" (or perhaps dd/MM/yyyy) and time in...
2
1427
by: markric | last post by:
I recently posted this message to microsoft.public.dotnet.framework.aspnet.webservices, but received no response, so I'm trying here in this group. I could really use some feedback. I'm working on a commercial application that will have data, web service, and client application tiers. I have no control over where any of these systems might be deployed, and it's fairly likely that users running the client application will be in different...
0
1644
by: antonyliu2002 | last post by:
I am having a hard time connecting to an oracle database from within Visual Web Developer (VWD) 2005 Express Edition. Check out the screen snap shot here: http://static.flickr.com/97/241874792_aebbadac2b_o.gif Here is the situation: 1. The oracle database runs on Machine A.
4
6366
by: sbowman | last post by:
I have a table with help desk ticketing information. There is a Date/Time open, Date/Time closed field both formatted as: MM/DD/YYYY hh:nn:ss I need to calculate the difference between these two times and then calculate the average of the difference. How do I go about this??? Help is much appreciated... Shelley
1
1877
by: Bill | last post by:
We have a corporate database that was upgraded to Oracle 10 and I can no longer link to or query a table that contains a Time Stamp field with Access 2003. I've tried the Microsoft ODBC driver and the Oracle 10 and Oracle 8 Driver. Any ideas as to how to access this data?
4
6813
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form allows the employee to enter their UserID and select "Login" or "Logout" and then click a submit. When the submit button is clicked, I want the application to dum the NT Userename, UserID, status (Login or Logout) and a date/time stamp into an MS Access...
1
2092
by: 6afraidbecause789 | last post by:
Hi - I am using a Date/Time Picker popup form for users to choose a a date and time for use on a separate entry form. The date/time on the entry form is actually entered automatically as a date/time stamp when a user enters a record. So, the popup form is only necessary when a user needs to change the date/time. To make this more user-friendly...there will be times when a user will be away from the computer, and therefore, will have to...
0
9953
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10768
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10868
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9591
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7984
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7137
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4231
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.