Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I can't find an answer for this problem.

If I have in my database data of datatypes like date and timestamp. Can the change of system date affect this saved data ? I mean, can these existing timestamp and date values be changed after the change of system date ?

Thank you very much :)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Changing the system date or the system time does not change values stored in tables.

Existing values can be changed using an UPDATE statement, though.

Datetime and timestamp columns behave differently on retrieval.

create table tz_test (
  ts timestamp not null,
  dt datetime not null
);

insert into tz_test values (current_timestamp, current_timestamp);

select * from tz_test;

ts                   dt
--
2013-06-27 09:46:14  2013-06-27 09:46:14  

Set a session timezone, and compare.

set time_zone = '-8:00';
select * from tz_test;

ts                   dt
--
2013-06-27 05:46:14  2013-06-27 09:46:14  
           ^^

Timezone support in MySQL

Docs show you how to change both client and server timezones for testing. You have to read that.

share|improve this answer
    
and if I changed the timezone and then made a SELECT. Will the values inside the select transformed using that timezone or displayed as they were in database before ? –  Reshi Jun 27 '13 at 13:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.