• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date format with MS Access database

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is something that drives me nuts:

I am using my jdbc with MSdatabase. Everything works GREAT except the date's format.

I am using the DD-MMM-YY format (e.g., 13-Oct-04 ) and the database saves it correctly (I initially set it up this way [data Type = Date/Time and format as above]).

When I input a date and look at the table I can see that the format is saved as I wanted BUT when I retrieve the information, the format given is: 2004-10-13 00:00:00

I had to write a method to correct this format (eliminate the 00:00:00) but I feel it's very inefficient. I looked at the MSdb date type for date only - nothing.

Anyone?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you retrieving the info? As a String? As a java.sql.Date? If the latter, you can format it anyway you want to.
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as a string
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
As Bear was getting at, use the getDate() method. This will return a Date object which you can then format using DateFormat. You just specify a formatter with the format of your choice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic