CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> Archive -> GotoCode Archive

 (CCS) - What DATETIME format in MySQL database?

Print topic Send  topic

Author Message
Labs4.com
Posted: 05/22/2002, 8:37 PM

Question for Codecharge support team regarding CC Studio B4
============================================================
What is the best suggested date/time format for storing date into MySQL database to be able to use all internal datetime functions of CCS?

In CC 2.0 I prefered to create UNIX timestamp by time() function and store it into database as
my_date INT(11) NOT NULL,

When I looked at example files of CCS they are using
my_date DATETIME NULL,
but if I tried to work with DATETIME I'm unable to format it properly to fit it into database, it just won't store because of improper format.

Here is an example:
I want to add into database datetime when record was created, this record will be written just once. After that during editing is this record just repeated but not edited.
In CC 2.0 this is easy (THIS IS RECORD) by Event Before Show Insert:

if((!isset($fldcreated)) || ($fldcreated = "") {
$fldcreated = time();
}
----------
Back formatting in preview (THIS IS GRID) - Event Before Show Insert:

$fldcreated=date("Y-m-d H:i:s");
----------

Please, explain me what format of datetime or timestamp do I have to use in CCS, I really don't get it.
Thank you

Josef
Labs4.com
Posted: 05/22/2002, 9:07 PM

I will add more information related to date/time in CCS:

Internal time/date functions (CurrentDate, CurrentTime, CurrentDateTime) doesn't work - all are returning 0 which is formatted to 12/31/1969 16:00:05
and if you will try to store it you will get
Warning: Unknown modifier '(' in ./Common.php on line 597


if you will replace Default: by
time()

you will get correct timestamp in form but inacceptable for Common.php
Warning: Unknown modifier '(' in ./Common.php on line 597

... wait a minute, this error comes in almost every issue ... this has probably nothing to do with database format (even if I change db format to VARCHAR(100)) ... sorry that I'm thinking outloud in public forum but it will help you follow my mind :)

So this is our problem now
Warning: Unknown modifier '(' in ./Common.php on line 597
<b>looks like a bug ... someone forgot additional '(' in source code.</b>

Josef

Nicole
Posted: 05/23/2002, 12:31 AM

Hello,
try the following:
do not add custom code to events. Just set Data Type to "Date", select 'Format' (i.e. display format), 'DBFormat' and set Default value CurrentDate.
I've tried this and formats were correct, but current date value wasn't applied. To overcome it create Before Show event and assign desired value to date field.
Labs4.com
Posted: 05/23/2002, 1:31 AM

I did exactly what you told me and nothing, it always returns 12/31/1969 (which is timestamp=0 or better timestamp="" ... do you really get there todays date or any date? are you able to store it and reveal back? if so, can you send me just short project file for test? my email ispepa@labs4.com

I can get todays date into text input by custom events, but I'm not able to store it into database ... it always returns this error
Warning: Unknown modifier '(' in ./Common.php on line 597

my devbox is Win2k, PHP4.04, MySQL 3.23.37, Apache 1.39, installed from Abriasoft package, properly tuned.
----------------------------------
IS HERE ANYBODY WITH SIMILAR OR SAME PROBLEM?
schaeff
Posted: 05/26/2002, 6:31 AM

Here's what I use and it works for me:
DATETIME in MySQL.

1. For direct access to DB by executing my own SQL in custom code I use
CCToSQL(strftime('%Y-%m-%d %H:%M:%S'),ccsDate)
for creation of the date values.

2. When filling fields of forms that update or insert a table entry I use:
function Schedule_Insert_OnClick() { //Schedule_Insert_OnClick @5-C3BFF3D4
//Custom Code @23-2A29BDB7
// -------------------------
global $Schedule;
$Schedule->created->SetValue(time());
return 1;
// -------------------------
//End Custom Code

in this example I have a hidden field "created" in the Record form "Schedule". The DataType is of the field is set to Date, Format and DBFormat are left empty while in the whole project's settings they are set to:
Date Display Format: dd.mm.yy H:nn:ss
Date Format of the used DB Connection: yyyy-mm-dd HH:nn:ss

Works like a charm for me!

Philippe
Labs4.com
Posted: 05/26/2002, 5:48 PM

... because if you are my guard angel where have you been so long!? :o))
just kidding, thanks a lot Phillipe for your help and stupid proof description of all settings, I'm going to cook another bucket of Colombian coffee and jump into CCS again.

According to functions used I assume you are part of development team because I didn't find any mention about them on whole internet.

Keep up the excellent work, CCS really "kix 'S'" ;-)
CodeCharge Support
Posted: 05/27/2002, 1:18 AM

Hello,
problem with date/time default value will be fixed in next CCS release. Please watch the announcements.
For now the workaround is to build Before Show event for the field and assign current date value there.

   


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.