Re: MySQL Date problem
Timestamp is the best bridge between java and mysql,I think. On Sun, Oct 19, 2008 at 4:48 PM, Rama [EMAIL PROTECTED] wrote: DATE TIME ZONE SENSITIVE DATETIME NOT SENSITIVE TO TIME ZONE TIMESTAMP TIMEZONE SENSITIVE iam getting the above problem as date is timezone sensitive.i resolved it by changing the field type from date to string. YOu can use any method to fill the DATE field of mysql .which method we use to fill mysql date is not important in this context. On Sun, Oct 19, 2008 at 1:33 PM, Roland Kaber [EMAIL PROTECTED] wrote: SK wrote: 2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama Hi What about using the STR_TO_DATE function to transform the java Date as a MySQL Date: STR_TO_DATE('19/10/2008', '%m/%d/%Y')? To transform this back into the original format, you may use the DATE_FORMAT function: DATE_FORMAT('2008-10-19', '%d/%m/%Y). Best regards Roland -- I'm a MySQL DBA in china. More about me just visit here: http://yueliangdao0608.cublog.cn
Re: MySQL Date problem
iam sorry iam facing same problem with the datetime iam confused and working/investigating on it. Problem is : Java Program MYSQL - -- - Default timezone : GMTDefault Timezone : GMT+5:30 program trying to store date : 2008-10-20 12:23:09-stored as : 2008-10-20 12:23:09 program trying to retrieve print date : 2008-10-20 06:23:09--- 2008-10-20 12:23:09 (here is the problem, i did not get what i stored time is less by 5:30 hrs) regards rama On Tue, Oct 21, 2008 at 5:46 AM, Moon's Father [EMAIL PROTECTED]wrote: Timestamp is the best bridge between java and mysql,I think. On Sun, Oct 19, 2008 at 4:48 PM, Rama [EMAIL PROTECTED] wrote: DATE TIME ZONE SENSITIVE DATETIME NOT SENSITIVE TO TIME ZONE TIMESTAMP TIMEZONE SENSITIVE iam getting the above problem as date is timezone sensitive.i resolved it by changing the field type from date to string. YOu can use any method to fill the DATE field of mysql .which method we use to fill mysql date is not important in this context. On Sun, Oct 19, 2008 at 1:33 PM, Roland Kaber [EMAIL PROTECTED] wrote: SK wrote: 2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama Hi What about using the STR_TO_DATE function to transform the java Date as a MySQL Date: STR_TO_DATE('19/10/2008', '%m/%d/%Y')? To transform this back into the original format, you may use the DATE_FORMAT function: DATE_FORMAT('2008-10-19', '%d/%m/%Y). Best regards Roland -- I'm a MySQL DBA in china. More about me just visit here: http://yueliangdao0608.cublog.cn
Re: MySQL Date problem
hi martin,Thanks, But my problem is Why it is printing wrong date ( 2008-10-20 06:23:09 ) instead of ( 2008-10-20 12:23:09 ) what is going wrong here? On Tue, Oct 21, 2008 at 7:33 AM, Martin Gainty [EMAIL PROTECTED] wrote: look at the MySQL doc to figure out whats going on default MySQL format is -MM-DD HH:MM:SS but you can display in the format you want http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format changing the default format coming into Java can be achieved using SimpleTextDateFormat as this example caller.. String fmt = new String(-MM-DD HH:MM:SS); Date visited = new Date(); String format(Date visited,String fmt) { SimpleDateFormat sdf = new SimpleDateFormat(fmt); //PLACE whatever format you need here FieldPosition pos = new FieldPosition(0); StringBuffer empty = new StringBuffer(); StringBuffer date = sdf.format(visited, empty, pos); return date.toString(); } I posted this earlier in the weekend but for some reason you were blocked Martin __ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. Date: Tue, 21 Oct 2008 07:16:40 +0530 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: MySQL Date problem CC: mysql@lists.mysql.com; [EMAIL PROTECTED]; [EMAIL PROTECTED] iam sorry iam facing same problem with the datetime iam confused and working/investigating on it. Problem is : Java Program MYSQL - -- - Default timezone : GMT Default Timezone : GMT+5:30 program trying to store date : 2008-10-20 12:23:09-stored as : 2008-10-20 12:23:09 program trying to retrieve print date : 2008-10-20 06:23:09--- 2008-10-20 12:23:09 (here is the problem, i did not get what i stored time is less by 5:30 hrs) regards rama On Tue, Oct 21, 2008 at 5:46 AM, Moon's Father [EMAIL PROTECTED]wrote: Timestamp is the best bridge between java and mysql,I think. On Sun, Oct 19, 2008 at 4:48 PM, Rama [EMAIL PROTECTED] wrote: DATE TIME ZONE SENSITIVE DATETIME NOT SENSITIVE TO TIME ZONE TIMESTAMP TIMEZONE SENSITIVE iam getting the above problem as date is timezone sensitive.i resolved it by changing the field type from date to string. YOu can use any method to fill the DATE field of mysql .which method we use to fill mysql date is not important in this context. On Sun, Oct 19, 2008 at 1:33 PM, Roland Kaber [EMAIL PROTECTED] wrote: SK wrote: 2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama Hi What about using the STR_TO_DATE function to transform the java Date as a MySQL Date: STR_TO_DATE('19/10/2008', '%m/%d/%Y')? To transform this back into the original format, you may use the DATE_FORMAT function: DATE_FORMAT('2008-10-19', '%d/%m/%Y). Best regards Roland -- I'm a MySQL DBA in china. More about me just visit here: http://yueliangdao0608.cublog.cn -- You live life beyond your PC. So now Windows goes beyond your PC. See howhttp://clk.atdmt.com/MRT/go/115298556/direct/01/
Re: MySQL Date problem
2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama
Re: MySQL Date problem
i figured out the root cause of the problem. 1) Java TIME ZONE is GMT --- storing DATE (2008-10-19 which is in GMT ) 2) storing the above date in GMT to mysql 3) MYSQL TIME ZONE IS GMT+05:30 4) as mysql time zone is GMT+05:30 it is viewing the date as (2008-10-19) @ GMT+05:30 5) when i retrieved the date from mysql (GMT +05:30) -Java (GMT) 2008-10-19 @ GMT+05:30 --- 2008-10-18 18:30 (GMT) converted to the above is the reason why it is printing the previous day date. On Sun, Oct 19, 2008 at 1:15 PM, SK [EMAIL PROTECTED] wrote: 2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama
Re: MySQL Date problem
The above argument applies to only MYSQL DATE field (timezone sensitive) where as in the case DATETIME Field it does not do any conversion gets what we store (timezone insensitive) in the case of TIMESTAMP Field it gets converted between UTC and local timezone. (timezone sensitive) On Sun, Oct 19, 2008 at 1:27 PM, Rama [EMAIL PROTECTED] wrote: i figured out the root cause of the problem. 1) Java TIME ZONE is GMT --- storing DATE (2008-10-19 which is in GMT ) 2) storing the above date in GMT to mysql 3) MYSQL TIME ZONE IS GMT+05:30 4) as mysql time zone is GMT+05:30 it is viewing the date as (2008-10-19) @ GMT+05:30 5) when i retrieved the date from mysql (GMT +05:30) -Java (GMT) 2008-10-19 @ GMT+05:30 --- 2008-10-18 18:30 (GMT) converted to the above is the reason why it is printing the previous day date. On Sun, Oct 19, 2008 at 1:15 PM, SK [EMAIL PROTECTED] wrote: 2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama
Re: MySQL Date problem
SK wrote: 2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama Hi What about using the STR_TO_DATE function to transform the java Date as a MySQL Date: STR_TO_DATE('19/10/2008', '%m/%d/%Y')? To transform this back into the original format, you may use the DATE_FORMAT function: DATE_FORMAT('2008-10-19', '%d/%m/%Y). Best regards Roland -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL Date problem
DATE TIME ZONE SENSITIVE DATETIME NOT SENSITIVE TO TIME ZONE TIMESTAMP TIMEZONE SENSITIVE iam getting the above problem as date is timezone sensitive.i resolved it by changing the field type from date to string. YOu can use any method to fill the DATE field of mysql .which method we use to fill mysql date is not important in this context. On Sun, Oct 19, 2008 at 1:33 PM, Roland Kaber [EMAIL PROTECTED] wrote: SK wrote: 2008/10/19 Rama [EMAIL PROTECTED] hi, iam using java,hibernate,mysql i am storing *19-10-2008 (*of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field. when i retrieve the same date from mysql to java it is being displayed as *18-10-2008 18:30:00 GMT * i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario? there are a lot of mothods to express data in java,but in mysql only have one type. may be types not match. i think you should storing 19-10-2008 to mysql char(10) field. --rama Hi What about using the STR_TO_DATE function to transform the java Date as a MySQL Date: STR_TO_DATE('19/10/2008', '%m/%d/%Y')? To transform this back into the original format, you may use the DATE_FORMAT function: DATE_FORMAT('2008-10-19', '%d/%m/%Y). Best regards Roland