Answer the question
In order to leave comments, you need to log in
How to work with date written in a string?
For example, I have records in the database: last name and date. The date is in the format: dd.mm.yyyy . Is it possible to somehow search by day or month separately? The search goes through the loop if(input_data.equals(current) -> display the record on the screen.
Answer the question
In order to leave comments, you need to log in
it all depends on how you are going to work with the data. You've specified the "Java" tag, but you're still talking about data. With a million rows and 20 columns in a table, your application will run very slowly if it doesn't drop dead.
conversion in Java code, you need to create a formatter that will then convert string data to date format.
SimpleDateFormat frm= new SimpleDateFormat("dd.mm.yyyy");
String tst = "17.05.2014";
try {
Date date = frm.parse(tst);
System.out.println(date);
System.out.println(frm.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
SELECT EXTRACT(YEAR FROM DATE expDate) FROM Table1
where EXTRACT(MONTH FROM DATE expDate) = 2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question