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 format issues

Print topic Send  topic

Author Message
kirchaj

Posts: 215
Posted: 08/11/2008, 12:38 PM

What I thought was going to be easy has become difficult.

I have a label in which I do a ccdlookup

$stuteach->physical->SetValue(CCDLookUp("physical","admit","ssno=".$stu_ssno,$DBedtechaccount));

to get a value of a date field. If I leave the label as a text field the value comes out 2008-08-11. If I set the label to a date type, no matter what date is entered in the database, I get 12/31/1969.

Ultimately I need to get the format of this label to be mm-dd-yyyy. I have played with ccdateformat to no avail. Does anyone have any suggestions?

Thanks.
TK
View profile  Send private message
datadoit
Posted: 08/11/2008, 2:31 PM

Start by verifying that your control has it's DBFormat set properly.
kirchaj

Posts: 215
Posted: 08/12/2008, 5:57 AM

Thanks datadoit.

Unfortunately it does not seem to make any difference. The postgres database field is set to date and the field contains ex. 2008-11-09. If my label is set to text, that is exactly what I see. If I set it to date, I get 12/31/1969 no matter what date is in the field.

TK
View profile  Send private message
datadoit
Posted: 08/12/2008, 8:37 AM

In your form or grid control field's Properties, under the Data tab, you
should have:

Data Type: Date
Format: mm/dd/yyyy
DBFormat: yyyy-mm-dd
kirchaj

Posts: 215
Posted: 08/12/2008, 9:21 AM

datadoit,

I have tried that with the same results : ( 12/31/1969

I keep wondering if it is because it is a label and not a database column. Or the fact that I am using the before show event in a record form.

Just thinking out loud.

TK
View profile  Send private message
datadoit
Posted: 08/12/2008, 10:16 AM

kirchaj wrote:
> I keep wondering if it is because it is a label and not a database column. Or
> the fact that I am using the before show event in a record form.
>
> ---------------------------------------

That's exactly it. Try this:

$stuteach->physical->SetValue(CCFormatDate(CCParseDate(CCDLookUp("physical","admit","ssno=".$stu_ssno,$DBedtechaccount),
array("yyyy","-","mm","-","dd")), array("mm","/","dd","/","yyyy")));

Parse the date (which is look'ed up), then format that parsed date.

I also -think- there's a way to do this without coding at all using
DLookup for the label control, and setting the label to Date format.
kirchaj

Posts: 215
Posted: 08/13/2008, 5:50 AM

datadoit,

Thanks a lot. Your example did not work but it gave me what I need to get it done. I may not always code in the most concise way, but I understand it and it works (most of the time :) ).

Thanks again.
TK
View profile  Send private message
datadoit
Posted: 08/13/2008, 6:51 AM

Here's how to do it without a single bit of coding:

Define your label properties as normal.

Name: Label1
Control Source Type: Database Column
Control Source:
Data Type: Date
Format: GeneralDate
Default Value:
Content: Text
DBFormat: yyyy-mm-dd HH:nn:ss

Then, in your label's Events, choose Server->Before Show, Add Action,
choose DLookup. Then in the DLookup properties:

Expression: your date field
Domain: the table you're looking into
Criteria: any WHERE parameters
Connection: YourConnection
Convert result to: Date
Type of Target: Control
Target: Label1

That's it.
kirchaj

Posts: 215
Posted: 08/13/2008, 7:23 AM

datadoit,

Thanks for explaining this simply for me. It took me a little searching, but I was able to figure out the search criteria and it works like a charm. You have taught me two new things in two days.

Thank you very much.

TK
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.