Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB2 date format

 
giribabu rosi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually u should help me i went IBM site also searched all documents
quick unstd:i want to change mm-dd-yyyy to dd-mm-yyyy in db2

am using checkdate as varchar(64),but
when am writing query

select * from table1 where chequedate between ('12-10-2000') and ('12-04-2005')


it has not displaying any value in SQL prompt

table1 has
------
Chequedate
11-11-2000
12-03-2001
09-12-2002
12-12-2003
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you storing dates as varchars? Does DB2 not support proper date types?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giribabu,
Welcome to JavaRanch!

As Paul suggested, you should use a date value. I use db2 and it works fine, just like any other database. Note that your query may not return the expected value. As far as strings are concerned, '01-01-2003' would not be returned by the query. However, it should be logically since it is between the values as dates.

If you must do this using varchars, take a look at the substring function. It can rearrange the columns of output for you. You really should compare using a yyyy-mm-dd format, so it is at least logically coherent.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic