Dear all,

I get the following problem: My users register on my website and enter a date of birth into the database (Mysql, DATETIME field).

Now I would like to create a query that shows the upcoming birthdays within X days. For example:

name [varchar(25)] :Tim
birthday [DATETIME] : 1984-01-23

How can I create a query that shows that I have my birthday in 7 days, example: "Tim will be 30 in 7 days"

The problem I'm facing is the YEAR in the datetime field, can anyone help me?

Thanks in advance!

Recommended Answers

All 3 Replies

I agree. Storing a timestamp in a int field would be by far better as more functions would be available for the the job. Then after having the timestamp you can perform math operations to check dates and everything since a timestamp is number of seconds since 1980.

You were slightly out, its is since 1/1/1970 :P

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.