CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Date woes with mySQL/PHP/Apache

Print topic Send  topic

Author Message
lurch99

Posts: 47
Posted: 11/14/2004, 10:56 AM

Hi Folks,

I am struggling to get CCS to format a date for me on a grid.

In my database is a field that has a Unix timestamp that looks like this: 20041111203724

And I'm pretty sure I've experimented with all the different options in CCS to format that into a "normal" date, such as November 11, 2004, 2:30PM (or whatever the above translates to).

Any help would be MUCH appreciated.

Lurch
View profile  Send private message
mrachow


Posts: 509
Posted: 11/14/2004, 11:34 AM

That don't look like a timestamp for me.

You can use
http://www.csgnetwork.com/unixds2timecalc.html
to look for the date you get on this.

But beside this what database do you use?

Regards,
Michael
_________________
Best regards,
Michael
View profile  Send private message
lurch99

Posts: 47
Posted: 11/14/2004, 11:51 AM

Michael,

Well, I thought it was a timestamp. It is the result of now() in mySQL, and I use it to record the time of my file uploads. Is there a better way to do this?

I use mySQL and PHP.

Lurch
View profile  Send private message
DonB
Posted: 11/14/2004, 12:05 PM

I suggest you use a real Timestamp data column. MySql will automatically
update it's value when the row is updated, you don't need to include it as
part of the update at all .


--
DonB

http://www.gotodon.com/ccbth
lurch99

Posts: 47
Posted: 11/14/2004, 12:14 PM

Don, thanks for the tip, but I thought that was what I was doing.

Could you please explain in very simple terms how to set this up to work as you suggested in CCS?

Yes, I'm a newbie, but I'm making great strides, so apologies for the newbie question. If you can communicate how to do this, it would be very useful for me and other newbies, too. Thanks!

Lurch
View profile  Send private message
peterr


Posts: 5971
Posted: 11/14/2004, 4:27 PM

lurch99,

So, you already have the dates written to the database and just have problems with displaying them?
If you want to display the dates correctly then make sure that you have specified in the "DBFormat" property the real format that is stored in the database. Since you gave an example of "20041111203724" then possibly the DB format should be "yyyymmddHHnnss".

You can also specify that format in the "Date Format" field of your Database connection (Server tab). Then the "DBFormat" property of date controls can be blank.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
lurch99

Posts: 47
Posted: 11/14/2004, 5:30 PM

Peterr,

Thanks for your reply.

I'm still not getting anything on the live page with the settings you suggested.

The Data Type should be "date" correct, and not integer or text, right? If I choose integer or text at least I get the unformatted string.

And then, would the Format box prevent the data from being produced for any reason? I have tried all the different settings.

Cheers, Lurch
View profile  Send private message
klwillis


Posts: 428
Posted: 11/15/2004, 10:14 AM

Use a timestamp field within your MySQL DB as Don suggested.

Then if you'd like to display this field, make sure you define it as
a text field and use one of the PHP date formatting routine to
display the date as you like.


_________________
Kevin Willis, VP/CIO
HealthCare Information Technology Specialist
http://www.nexushealthcare.com
"Fast - Convenient - Quality-Care"

Medical Software Consulting Services
Email : klwillis@nexushealthcare.com
Skype : klwillis2006
View profile  Send private message
thesoftwareplanet.com
Posted: 11/15/2004, 1:05 PM

Use the FieldType as "DateTime", use PHP MyAdmin to do so properly......

just my 2 cents
lurch99

Posts: 47
Posted: 11/15/2004, 9:44 PM

Success!

Thank you all for your help.

For some reason, I simply cannot format the timestamp field.

However, the "datetime" field works like a champ. Not sure why this is the case but at this point I'm thrilled it's working as I hoped.

Thanks again for your patience and help!

Lurch
View profile  Send private message
DonB
Posted: 11/16/2004, 6:26 AM

I had this problem myself. After many (all unsuccessful) combinations of
date-format specifiers for the project, database and the datafield itself, I
finally changed the datafield (in my case a Label) to have a Control Source
Type of "Database Expression" and Control Source of
"DATE_FORMAT(mytimestamp,'%Y-%m-%d')". The Data Type for the Label is set
to "Text".

I haven't explored the "why" but it appears that a Timestamp is stored or
represented differently from a DateTime, so the CCS formatting routines
fail. The Timestamp is output as an "unpunctuated" string: yyyymmddhhmmss
and the DATE_FORMAT() function gave me the date values I needed to display.
It might be that a DateTime field is output as yyyymmddThh:mm:ss, (note the
"T" between date and time parts) but I can't remember what I was getting at
the time.

Of course, with the function in the SELECT, this will impact inserts/updates
(let's say you used the Ed Grid instead), so you'll have to resort to a
custom insert/update if you use this technique.

--
DonB

http://www.gotodon.com/ccbth


"lurch99" <lurch99@forum.codecharge> wrote in message
news:54197aa45c655b@news.codecharge.com...
> Hi Folks,
>
> I am struggling to get CCS to format a date for me on a grid.
>
> In my database is a field that has a Unix timestamp that looks like this:
> 20041111203724
>
> And I'm pretty sure I've experimented with all the different options in
CCS to
> format that into a "normal" date, such as November 11, 2004, 2:30PM (or
> whatever the above translates to).
>
> Any help would be MUCH appreciated.
>
> Lurch
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

lurch99

Posts: 47
Posted: 11/16/2004, 7:17 AM

Don,

That corresponds with my frustrating experience, too, and I wonder if this is some minor bug or oversight in CCS, as I was surprised to see the date and time formatted correctly when looking at my timestamp data in phpmyadmin. So it must work somewhere but I need the fast and easy solution and am thankful datetime works just fine.

Thanks again for your help.

Lurch
View profile  Send private message
DonB
Posted: 11/16/2004, 9:20 AM

I don't know what it is that makes the date not display. I just went back
to try duplicating the problem because I wanted to see how a "datetime" is
displayed when set to text. Funny thing is, it seems to be formatting
datetime and timestamp just fine. I have the Connection set with date
format of "yyyy-mm-dd HH:nn:ss" for the server side and "yyyy-mm-dd" in the
project's date format property.

Yet, I've fought with the formatting many times, never getting it to display
quite right. Maybe the trick is (a) the specific combination of default
formatting strings (above) and the fact that was set BEFORE I created my
test grid? I do think I found this a problem when I created a grid THEN
realized I hadn't set the format stings. Beats me, but the test I just ran
was working with no problem at all.

--
DonB

http://www.gotodon.com/ccbth
peterr


Posts: 5971
Posted: 11/17/2004, 2:28 AM

The format 'yyyymmddHHnnss' should work OK for the Timestamp field type. Please let me know if this doesn't work for someone for some reason.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
tonyk

Posts: 163
Posted: 11/17/2004, 9:01 PM

I've used DATETIME for my MySQL dates from the outset and have never had any problems with it, are there any advantages in using a DATESTAMP format in the database?
Tony
View profile  Send private message
ryuuguu

Posts: 13
Posted: 11/25/2004, 4:38 PM


I am using CSS 2.3.2.24
and in the drop down list for DBformat- yyyymmddHHnnss - is not an option can this be changed for future version pls. it works but it is not obvious that I should have used it.

Cheers,
Grant
View profile  Send private message
ryuuguu

Posts: 13
Posted: 11/25/2004, 5:31 PM

P.S.

Thanks for the info how show timestamps it saved me a lot of work.

Cheers
Grant
View profile  Send private message
Macamba
Posted: 12/18/2004, 9:23 AM

CCS has different date settings:

1)
Menu: project, Option: 'settings', tab: 'project'.
Set the 'Date Display Format' attribute to what you prefer.
For example: dddd, mmmm d, yyyy

2) On the grid form fill in the following for the date field:
Data type: Date
Format: Long Date
DBFormat: yyyy-mm-dd HH:nn:ss (your unix timestamp)

Probably you forgot to set the dbformat on field level.

Macamba


lurch99 wrote:
> Hi Folks,
>
> I am struggling to get CCS to format a date for me on a grid.
>
> In my database is a field that has a Unix timestamp that looks like this:
> 20041111203724
>
> And I'm pretty sure I've experimented with all the different options in CCS to
> format that into a "normal" date, such as November 11, 2004, 2:30PM (or
> whatever the above translates to).
>
> Any help would be MUCH appreciated.
>
> Lurch
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.