SELECT NOW();
SELECT CURDATE();
SELECT CURTIME();
SELECT DATE_FORMAT(NOW(), '%d/%m/%Y') FROM DUAL
SELECT DATE_FORMAT(CURDATE(), '%d/%m/%Y') FROM DUAL
or
SELECT DATE_FORMAT(SYSDATE(), '%d/%m/%Y') FROM DUAL
// String query = "SELECT booking_id,type_id,title,room_id,booking_date,start_time,end_time,description,attendy_people FROM rbs_room_booking where booking_id="+bookingid+"";
//mySQL date format
String query = "SELECT booking_id,type_id,title,room_id,booking_date,DATE_FORMAT(start_time, '%d/%m/%Y')start_time,DATE_FORMAT(end_time, '%d/%m/%Y')end_time,description,attendy_people FROM rbs_room_booking where booking_id="+bookingid+"";
See the following Example :
//search criteria :: mySQL date format
( SELECT DATE_FORMAT(booking_date, '%d/%m/%Y')booking_date FROM rbs_room_booking )
// String query = "SELECT booking_id,type_id,title,room_id,DATE_FORMAT(booking_date, '%d/%m/%Y')booking_date,DATE_FORMAT(start_time, '%d/%m/%Y')start_time,DATE_FORMAT(end_time, '%d/%m/%Y')end_time,description,(SELECT user_name FROM rbs_user WHERE user_id = a.entered_by)user_name FROM rbs_room_booking a where booking_id="+bookingid+"";
//search criteria :: get time from datetime column sql
( SELECT CAST(start_time AS TIME)starttime,CAST(end_time AS TIME)endtime FROM rbs_room_booking )
String query = "SELECT booking_id,type_id,title,room_id,DATE_FORMAT(booking_date, '%d/%m/%Y')booking_date,CAST(start_time AS TIME)starttime,CAST(end_time AS TIME)endtime,description,(SELECT user_name FROM rbs_user WHERE user_id = a.entered_by)user_name FROM rbs_room_booking a where booking_id="+bookingid+"";
No comments:
Post a Comment