This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Date / Time problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Date / Time problems " Watch "Date / Time problems " New topic
Author

Date / Time problems

john ersan
Greenhorn

Joined: Dec 24, 2005
Posts: 10
Hi Guys..

I'd like to ask how to get full Date and Time from mssql with jdbc?

for eg.




this datex only takes Date from the database ..

but, in database there is also time too..

how can i take both of it ?

thanx for ur time !


Good Coding...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
Instead of using getDate, have you looked at what getTime and getTimestamp return?


Ping & DNS - my free Android networking tools app
john ersan
Greenhorn

Joined: Dec 24, 2005
Posts: 10
yes i checked..

and the problem is when i use them they say No data found

in mssql , my data is stored as DateTime

for e.g.



if someone can give me a link or code it would be great..

thx 4 ur time..!
[ January 12, 2006: Message edited by: john ersan ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
I'm not too familiar with the JDBC/ODBC bridge - is there any particular reason you couldn't use a better driver like jTDS?
john ersan
Greenhorn

Joined: Dec 24, 2005
Posts: 10
not really..

i didnt even know a better driver exists called jtds..

I'm really rookie about java, i've been coding with it almost for two months by now..

I'm done with my grad. project that i had to use java for some oop metrics.. the last thing i have to do is;
get the Time from mssql / DateTime field and put it into a JTextField and do some inheritance between classes.. I'm stuck
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
If you don't want to go the jTDS route, and getTime[stamp] really doesn't work with the JDBC/ODBC bridge, you could use getString, which returns the date and time as a string. You can then parse the string to extract the date and time yourself.
john ersan
Greenhorn

Joined: Dec 24, 2005
Posts: 10
thanx

i just get it as a string and put into JTextField with substring();

thx again
 
wood burning stoves
 
subject: Date / Time problems
 
Similar Threads
Between Syntax
Calculating days between two dates
Sorting in MYSQL
how to change the date,Time format after accessing it from the database
Updating the value of Text box