CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Trouble with insertion of current time string

Print topic Send  topic

Author Message
Gene

Posts: 14
Posted: 11/29/2007, 4:22 AM

I have a hidden field.
Here are the attributes:

The name of the field and the database column is 'Time'
Data Type: Date
Default Value: CurrentDateTime
DBFormat: yyyy-mm-dd HH:nn:ss

When I submit, the query that is generated set the hours, minutes and seconds to zero:

From the server's query log:

INSERT INTO contacts(LastName, FirstName, JobTitle, EMailAddress, CompanyName, Phone, AddressLine1, AddressLine2, City, State, Province, Country, PostalCode, Reason, Comments, Time) VALUES('John', 'Doe', NULL, 'someone@hotmail.com', 'Cafe.com', '34567890', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Preview A Course', NULL, '2007-11-29 00:00:00')

The data type of the column was DATETIME, and I also tried using the TIMESTAMP datatype.
The database is currently MySQL 5.01 (but the final product will need to run on 3.23)
The version of CCS is 3.2.0.2

Please note:
I have tried using yyyymmddHHnnss, yyyymmddhhnnss, and other variations of the mask, but have been unable to get CCS to output a query that contains accurate values for the time.

What am I doing wrong?

Thanks for any insight you can offer.

Gene
View profile  Send private message
datadoit
Posted: 11/29/2007, 4:34 AM

Start by verifying that your Project Settings, database connection
date/time format is set to yyyy-mm-dd HH:nn:ss.
Gene

Posts: 14
Posted: 11/29/2007, 6:05 AM

It is, and it's set identically in both places (the specific field mask and in the project settings).

View profile  Send private message
Gene

Posts: 14
Posted: 11/29/2007, 1:56 PM

If someone can tell me where in the underlying PHP code I can find at the raw datetime variable after it's initialized but prior to parsing against the DBFormat mask, I can probably track down the problem.

Thanks!

View profile  Send private message
datadoit
Posted: 11/29/2007, 2:15 PM

Gene, rather than setting the Default Value property, in the control's
Before Show add an action to Retrieve Value for Control, set the Source
Type to Expression, and Source Name to mktime().

See if that works for you.
Gene

Posts: 14
Posted: 11/30/2007, 6:16 AM

No luck. Here's the code:

//End contacts_Time_BeforeShow

//Retrieve Value for Control @23-17B3C365
$Container->Time->SetValue(mktime());
//End Retrieve Value for Control

Here's the value from the generated query:
...NULL, '2007-11-30 00:00:00')
View profile  Send private message
Gene

Posts: 14
Posted: 11/30/2007, 6:28 AM

I also tried setting the data type on the control to Text and removing the DBFormat mask to see what the raw string from mktime looked like. Here's the value from the generated query string:
'11/30/2007'.

That looks really odd to me. I thought mktime() was supposed to produce a Unix-style time string.

View profile  Send private message
Gene

Posts: 14
Posted: 11/30/2007, 6:38 AM

OK, I changed the control to visible (I suppose I could have simply looked at the page source |:o)
the raw mktime() string looks like this:
1196433275
View profile  Send private message
DonB
Posted: 11/30/2007, 7:10 AM

You should not specify the DBFormat. Leave that empty, so the connection
settings apply. Then change the Data Type to 'Date' and the Format to H:nn
or H:nn:ss.

Note, however, that MySQL stores all date and time fields as yyyy-mm-dd
hh:mm:ss. So a 'time' value or 3pm will be stored as 0001-01-01 15:00:00.

--
DonB

http://ccswiki.gotodon.net


"Gene" <Gene@forum.codecharge> wrote in message
news:5474eaf110181c@news.codecharge.com...
> I have a hidden field.
> Here are the attributes:
>
> The name of the field and the database column is 'Time'
> Data Type: Date
> Default Value: CurrentDateTime
> DBFormat: yyyy-mm-dd HH:nn:ss
>
> When I submit, the query that is generated set the hours, minutes and
seconds
> to zero:
>
> From the server's query log:
>
> INSERT INTO contacts(LastName, FirstName, JobTitle, EMailAddress,
CompanyName,
> Phone, AddressLine1, AddressLine2, City, State, Province, Country,
PostalCode,
> Reason, Comments, Time) VALUES('John', 'Doe', NULL, 'someone@hotmail.com',
> 'Cafe.com', '34567890', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Preview
A
> Course', NULL, '2007-11-29 00:00:00')
>
> The data type of the column was DATETIME, and I also tried using the
TIMESTAMP
> datatype.
> The database is currently MySQL 5.01 (but the final product will need to
run on
> 3.23)
> The version of CCS is 3.2.0.2
>
> Please note:
> I have tried using yyyymmddHHnnss, yyyymmddhhnnss, and other variations of
the
> mask, but have been unable to get CCS to output a query that contains
accurate
> values for the time.
>
> What am I doing wrong?
>
> Thanks for any insight you can offer.
>
> Gene
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Gene

Posts: 14
Posted: 11/30/2007, 8:02 AM

DonB,

Thank you!

Problem solved.

You got it. The solution varied slightly in my case, because I want to store the full date and time together. Therefore, I have to set the (display) Format property on the control to:
mm/dd/yyyy h:nn AM/PM

The date format for the connection is set to yyyy-mm-dd HH:nn:ss

Bingo!

View profile  Send private message

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.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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