I can't see my dates in MySQL. Need some help.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

I can't see my dates in MySQL. Need some help.

Post by Genteel Beaux »

I have my table set up so that it automatically enters the date and time in a field. At first, it was working fine. I could see the dates and the times. Now, all of the dates and times in each of the records are set back to the default. I don't know if I did anything. No matter what, all I get is 00000000000000 for timestamps and 0000-00-00 00:00:00 for data/time. Does anyone know what causes this?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you checked to see what the dates and times look like before you put them into the database, MySQL will just put a default value into the field if the data is not formatted correctly. Has all the previous data also been affected? If so do you run any UPDATE SQL statements to alter dates and times that don't use the WHERE clause and thus affect all records.

Mac
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

Post by Genteel Beaux »

I don't have any code referencing the timestamp at all. I did that so I wouldn't have to worry about doing it in the code. I'm just using an INSERT() statement to add a new record. At first, everything was working fine. Then eventually, all my previous records (timestamps) have changed back to the default values. I don't have an UPDATE() statement at all. Now, it doesn't matter when I add a new record. It is always 000000000000 or 0000-00-00 00:00:00.
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

Post by Genteel Beaux »

Nevermind, I decided to go ahead and use the NOW() function in the SQL statement. I shouldn't have to relie on the SQL statement to do this, but now it works.
Post Reply