Hello,

I am just starting to get into mysql and have a quick question: I have a table that has a datetime field, and i simply want to store that datetime into a variable and be able to print it, and also compare it to the current date to see how many days have elapsed. when i run the fetch array command do I have to convert the variable into something else in order to display it on the screen?

Hi frenchwr and welcome to DaniWeb :)

This link will be useful for you, it is the reference manual for MySQL 5.1.

Are you storing the variables in PHP? PHP has a mysql_fetch_array function, which is why I thought this. Or are you working with another language, or purely in MySQL?

Hi frenchwr and welcome to DaniWeb :)

This link will be useful for you, it is the reference manual for MySQL 5.1.

Are you storing the variables in PHP? PHP has a mysql_fetch_array function, which is why I thought this. Or are you working with another language, or purely in MySQL?

I am storing the variables in php, then moving them into the database. I just simply am storing a datetime function, and would like to add 7 days to it then store it as another variable in the database if possible.

Yes, possible. Use date_add function.

Yes, possible. Use date_add function.

The date_add function is only for PHP version 5.3 or greater. Since 5.3 is due for general release later this year, I assume frenchwr cannot access that function.

What you need to do is use the date and strtotime functions to parse a date for seven days time. Check out this thread in the PHP forum where peter_nichol explains how to use these functions in conjunction with daylight savings. If you still have questions, repost and we will try to help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.