Kanishk Dudeja
Kanishk Dudeja

Reputation: 1221

MySQL TimeStamp +5 Hours

I have a timestamp column in my mysql table. It is storing timestamps according to UTC/GMT. Now i wish it to store in IST format which is +5 hours than UTC/GMT.

What would be the query to do that?

Upvotes: 0

Views: 3284

Answers (3)

jmail
jmail

Reputation: 6134

try this variety of conversation for the time stamp as following as:

SELECT NOW()+INTERVAL 5 HOUR;

SELECT DATE(COLUMN NAME)+INTERVAL 5 HOUR FROM t1(TABLANAME);

SELECT CONVERT_TZ(DATE(COLUMN NAME),'+1:00','+00:00') FROM t1(TABLANAME);

SELECT CONVERT_TZ(NOW(),'+1:00','+00:00');

SELECT CONVERT_TZ('2004-01-01 12:00:00','+1:00','+00:00');

refer this link in (http://www.tutorialspoint.com/mysql/mysql-date-time-functions.htm#function_convert-tz)

Upvotes: 0

i100
i100

Reputation: 4666

Select convert_tz(now(),'GMT','IST'); 

also

SELECT NOW()+INTERVAL 5 HOUR;

For more info look here

Upvotes: 3

Not Amused
Not Amused

Reputation: 962

You can use DATE_ADD in the select/where statement (up to your needs)... I think that's what you want.

DATE_ADD(date_column_name, INTERVAL 5 HOUR)

Upvotes: 2

Related Questions