Jump to content

Create a date string (dd/mm/yyy) from table with dd, mm and yyyy separated


bajangerry

Recommended Posts

Guys,

I am trying to create a date string of dd/mm/yyyy from a table that has the dd, mm and yyyy info in different columns. My problem is how to get the / in the string without getting errors.

So far I have the data query working fine, that is not the problem and I can echo as follows:

echo ($row->day);

echo ($row->month);

echo ($row->year);

 

and get for example 12082009 so the data access side of things is fine.

Now, how do I get this data into a string that, if echoed, will give me 12/08/2009 instead?

 

I need to use this string to test against another table that has the date in the format of dd/mm/yyyy in a single column.

 

Looking forward to your responses

Hi

 

Use mysql CONCAT() function to retrieve the data already formated.

You should really fix table in order to have only 1 column of type date and remove the other 3 columns.

 

In php the dot character is the concatenation symbol. example: echo 'Foo'.'-'.'bar';  //prints "Foo-bar"

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.