• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Selecting * and specific sysdate format

 
Patrick Ferguson
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone.

I have a situation that I'm unfamiliar with and you guys always do a great job of helping out.

I'm writing a dynamic file sync system based on multiple tables in a database. These tables do NOT have the same column structure so I have to use "Select * from...", BUT I need one of the columns which is a date and is present in every table to come back with the date AND time. Currently it only comes back with the date(yyyy-mm-dd). I know the time is in there because I can see it. But when I select it into my java program it only has the date.

I know I could specifiy the columns and use a to_char function to get what I need, but you have to understand that I HAVE to use "Select * from..."

Any advice?

Thanks,

Patrick
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34218
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patrick,
You can take advantage of a feature of JDBC: use ResultSet's getTimeStamp() method. This presumes you know which column number the date type is.

If not, you could probably figure it out from the database value and then call getTimeStamp(). Note that not all drivers support getting the same column twice, but most modern drivers should be ok.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic