Data type for Date calculations in PHP5

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
User avatar
technofreak
Forum Commoner
Posts: 74
Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:

Data type for Date calculations in PHP5

Post by technofreak »

Hi,

i have an expiry date and activation date values in the database. I require to find out those rows with expiry date that are one month from today's date, as well as rows with activation dates in the past one month.

I have declared the expiry_date and activation_date fields in my database table as varchar(10) to support mm/dd/yyyy format. I had no idea of doing calculations that I mentioned above when designing the databse. As i don't have much data in the database altering the data type of those fields is not an issue.

rather, I want to know whats the data type for date, which i can declare over my mysql database, that will be helpful for these PHP calculations. Can i use DATE and TIMESTAMP types for these ?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

the correct data type for date values is, obviously, DATE.
Post Reply