Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to excel date problem 1

Status
Not open for further replies.

QatQat

IS-IT--Management
Joined
Nov 16, 2001
Messages
1,031
Location
IT
Hi there,

sorry to post continuosly but coming from ASP my PHP is not up to scratch yet.

I have succesfully managed to export to excel the output of a page.



header("Content-Type: application/vnd.ms-excel; name='excel'");
header("Content-disposition: attachment; filename=" .date("Y-m-d").".xls");

include 'ReportTableHeading.Include';


the code above works perfectly but, when it comes to a datetime field it only outputs the time (00:00:00).

Changing the excel column setting to date at a later stage will show the correct date value.

Can I control excel's output to each single column?
If not, how do I avoid this and output only date with no time?

Thanks

Qatqat

Life is what happens when you are making other plans.
 
Yep,

SQL server.

Qatqat

Life is what happens when you are making other plans.
 
This works - header("Content-Type: application/vnd.ms-excel; name='excel'");
header("Content-disposition: attachment; filename=" .date("Y-m-d").".xls");

Some thing to do with using (") inside (') or vice versa...
 
Sorry this is the one that works...

header("Content-disposition: attachment; filename=" .date('Y-m-d').".xls");
 
When you do your select, why not use the

Date_format("format", date_field)

to get the correct date on the field?

Bastien

Cat, the other other white meat
 
Thank you Bastien,

although date_format does not work with MSSQL you gave me a good tip


select datepart and join YYYY/MM/DD into a variable


Thanks


Qatqat

Life is what happens when you are making other plans.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top