1. Query to find week day in PostgreSQL
select to_char(current_date,'Day');
Friday
select to_char(current_date,'Day');
Friday2. Query to find current day of week
select to_char(current_date,'D');6
3. Query to extract year and month from date in PostgreSQL
SELECTEXTRACT(YEAR FROM to_timestamp(column_name, 'YYYY-MM-DD')) years,
EXTRACT(MONTH FROM to_timestamp(column_name, 'YYYY-MM-DD')) months
FROM table_name
4. Query to find number of days between two dates in PostgreSQL
select '2015-05-22'::date - '2015-05-12'::date10
5. Query to display name of month in PostgreSQL
SELECT to_char(to_timestamp (4::text, 'MM'), 'TMmon')Apr
6. How to get fully qualified path name for a file in /src/Resources folder in Eclipse Java Project
className.getClass().getResource("/Resources")7. List all filenames in a particular directory using java
public List<String> listFiles(String location){List<String> fileNames = new ArrayList<String>();
File[] files = new File(location).listFiles();
for (File file : files) {
if (file.isFile()) {
fileNames.add(file.getName());
}
}
return fileNames;
}
No comments:
Post a Comment