Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

date problem

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using following query in my java page &its is returning null

("select * from tble where date='"+dcode+"';");

dcode is a variable containing date & time

please anyone help me

thanks
 
Ranch Hand
Posts: 247
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Aditi,

Check your Query on the query browser what is it returning?
that may give you an idea that problem is in query or anywhere else?

Regards
Raza
 
Ranch Hand
Posts: 222
Google Web Toolkit Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your whole code, as well as database content.

and SELECT * is not a good thing to do.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@razar thanks for your reply
when i run same query on my db then it returns properly

@Elchin thanks for your reply too but that code is not with me & i am not using '*' i am using whole query

but i think problem is somewhere else

thanks for reply & sorry for inconvinience
 
Raza Mohd
Ranch Hand
Posts: 247
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi aditi,

can you provide me the jsp code and the same Query you are using..?

Regards
Raza
 
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably need to convert the sql date to character.

select * from tble where to_char(date,'the format you need')='"+dcode+"';"

http://developer.postgresql.org/pgdocs/postgres/functions-formatting.html
 
Sheriff
Posts: 22017
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's assuming Aditi is using PostgreSQL. For MySQL, SQL Server or Oracle it may be different. So Aditi, please TellTheDetails.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use java.util.Date dcode=new java.util.Date();
 
It's a tiny ad only because the water is so cold.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic