By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,292 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

PHP: DATETIME is Object?

P: n/a
Hello,

We're using PHP to query the Access DB and publish the data on the web.

Query the DB:

$qry = odbtp_query("SELECT end_date,title FROM projects ORDER BY
end_date DESC");

Get the query results:

while( ($rec = odbtp_fetch_array($qry)) ) {
echo "end_date is $rec[0], title is $rec[1]<br>";
}

The outputs are:

end_date is Object, title is 'blah blah'
end_date is Object, title is 'lajd;fsakf'
.....

'end_date' is of type DATETIME in Access. How DATETIME is actually
stored in Acces? Can anybody give me an example? Why PHP shows it as
Object? What should I do if I want end_date to be printed in the 'F j,
Y' format, like 'March 31, 2005'?

I'd appreciate any help.

Bing

Apr 13 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I'm not sure what library you're using to connect to the Access
database - I know I've done this before without problems, but not with
these odbtp functions.

One approach would be to use some of the built-in date format functions
right in your SQL query - something like:

SELECT FORMAT(end_date,'mmmm d, yyyy') AS date, title FROM projects
ORDER BY end_date DESC

Apr 13 '06 #2

P: n/a
"AllenWhite" <co******@allenwhite.net> wrote in
news:11**********************@t31g2000cwb.googlegr oups.com:
One approach would be to use some of the built-in date format
functions right in your SQL query - something like:

SELECT FORMAT(end_date,'mmmm d, yyyy') AS date, title FROM
projects ORDER BY end_date DESC


I don't think the Access Expression Service is available from ODBC,
so that won't work.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Apr 14 '06 #3

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

DateTime data types are stored as Double numbers in Access tables.
E.g.:

Now = 4/13/2006 6:25:50 PM and is stored as 38820.7679398148

The integer is the number of days since 12/30/1899 (the ZEROth day).
The decimal is the number of milliseconds since midnight of the
indicated date.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRD76t4echKqOuFEgEQL6VwCg/2C45yozmB2g8NKPFNH9Vh/0U8QAn2wC
Mdz56o0CTfNigL07XbJP/GsJ
=j8Hq
-----END PGP SIGNATURE-----
du****@gmail.com wrote:
Hello,

We're using PHP to query the Access DB and publish the data on the web.

Query the DB:

$qry = odbtp_query("SELECT end_date,title FROM projects ORDER BY
end_date DESC");

Get the query results:

while( ($rec = odbtp_fetch_array($qry)) ) {
echo "end_date is $rec[0], title is $rec[1]<br>";
}

The outputs are:

end_date is Object, title is 'blah blah'
end_date is Object, title is 'lajd;fsakf'
....

'end_date' is of type DATETIME in Access. How DATETIME is actually
stored in Acces? Can anybody give me an example? Why PHP shows it as
Object? What should I do if I want end_date to be printed in the 'F j,
Y' format, like 'March 31, 2005'?

I'd appreciate any help.

Bing

Apr 14 '06 #4

P: n/a
MGFoster <me@privacy.com> wrote in
news:VU*****************@newsread1.news.pas.earthl ink.net:
DateTime data types are stored as Double numbers in Access tables.
E.g.:

Now = 4/13/2006 6:25:50 PM and is stored as 38820.7679398148

The integer is the number of days since 12/30/1899 (the ZEROth
day). The decimal is the number of milliseconds since midnight of
the indicated date.


That is not true. The decimal part is the fraction of a day since
midnight of the day indicated by the integer part. If it were
actually milliseconds, it would be much easier, since there'd be no
rounding inaccuracies.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Apr 14 '06 #5

P: n/a
David W. Fenton wrote:
MGFoster <me@privacy.com> wrote in
news:VU*****************@newsread1.news.pas.earthl ink.net:

DateTime data types are stored as Double numbers in Access tables.
E.g.:

Now = 4/13/2006 6:25:50 PM and is stored as 38820.7679398148

The integer is the number of days since 12/30/1899 (the ZEROth
day). The decimal is the number of milliseconds since midnight of
the indicated date.

That is not true. The decimal part is the fraction of a day since
midnight of the day indicated by the integer part. If it were
actually milliseconds, it would be much easier, since there'd be no
rounding inaccuracies.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Right you are. I must have been thinking of Unix time.

Therefore, the fraction .7679398148 means that almost 77 percent of the
day has passed.

Seconds in day = 86400

864000 * .7679398148 = 66349.99999872 seconds elapsed since midnight

(66349.99999872 / 60 ) / 60 = 18.4305555552 hours since midnight

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRD/NoYechKqOuFEgEQK21wCgqxAO8A5ujYmyepSCO77zOP+ST94Ao OD1
QCY40t8T07yKR2SJ9TQG+lXt
=vj+C
-----END PGP SIGNATURE-----
Apr 14 '06 #6

P: n/a
Bing,
How DATETIME is actually stored in Acces?
[...]
Why PHP shows it as Object?


Regardless of how Access stores datetime values internally, ODBTP
returns such values as a datetime object by default. You can change
this behaviour with an odbtp.datetime_format entry in PHP.INI...

http://odbtp.sourceforge.net/phpext.html#phpini

....or you can learn how to manipulate ODBTP's datetime object to get
the result you want.

IOW, this isn't really an Access question, it is an ODBTP question.

Apr 15 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.