Newsgroup: it.comp.lang.visual-basic
Titolo: CRYSTAL REPORT

Non riesco a stampare la data e l'ora di un campo date di access in crystal
report.
Se definisco il campo come date mi stampa solo la data e non l'ora, se lo
definisco come stringa mi stampa la data nel formato aaaammgg.
Qualcuno puņ aiutarmi ????

prova con questo
Crystal Report / MS Access Time Formats
Date:  4/23/94
Author:  Thomas Becker
Compuserve ID: 73473,1363
Subject: Format of MS Access Time fields in Crystal Reports
Crystal Report 2.0 (packaged with VB Pro 3.0) does not handle Time
formatting for MS Access fields defined as "Date/Time".  Crystal Report Pro
3.0 will handle Time formatting for MS Access ONLY if the database is
accessed via ODBC.
I have developed three Crystal Reports formulas that will format Time from
an MS Access database in the following formats:
    Format FileName
    ------ --------
  12:00 AM/PM Time_1.txt
  24:00  Time_2.txt
  24:00:00 Time_3.txt
The only catch is, the MS Access Time field must be defined as a DOUBLE (not
Date/Time).  This is not a problem if you maintain your Date and Time fields
on your database as separate fields. These formulas will NOT work for
fields that are used for Date/Time Stamps (Date and Time in the same field).
The reason is, that Crystal Reports will no longer recognize the Date part
of the field as a Date (and I have not, and probably will not provide a
formula that will convert a DOUBLE to a Date field).
I have provided three text files for the Time format formulas, as listed
above.  These formulas should work in Crystal Reports 2.0 or 3.0 (Pro or
Standard).
Following are the steps to install into Crystal Reports:
  1. Run Crystal Reports Report designer.
  2. Load an existing report or start a new one.
  3. Minimize Crystal Reports down to an icon.
  4. Open a text editor (like Windows Note Pad).
  5. Load the desired Time Format Text file (Time_1.txt, Time_2.txt,
     or Time_3.txt).
  6. Highlight all text in the file and Copy to the Clipboard.
  7. Double click on the Crystal Reports icon to re-activate Crystal
     Reports.
  8. Select Insert|Formula from the main menu.
  9. Assign a new formula name and press enter.
 10. Press Shift+Insert to paste the Time format text into your
     formula.
 11. On the 4th line of the formula is a database field name
     "{Time.Time}".  Change this field name to your Time field name.
 12. Click the "Accept" button and place the field on your report.
You will need to create a formula for each Time field on your report.
The other concern with changing your MS Access Time fields to DOUBLE, is
how do you handle these field in your VB program.  Most of my Time fields
are updated and displayed using TrueGrid.  TrueGrid will handle a Time field
in "Date/Time" or "DOUBLE" format equally well.  Just set the properties
Format to "hh:mm AM/PM" or "hh:mm:ss" or what ever.
For a Text Box, assign the "TEXT" property of the text box to a Format,
for example:
  Text1.Text = Format(t#,"hh:mm AM/PM")
    or
  Text1.Text = Format(Data1.Recordset("Time"),"hh:mm AM/PM")
If you are currently using a bound Text box, you will need to change it to
unbound and place the second example above in the Data Control Reposition
Event.
This isn't the best answer, but it may help until Crystal Services gets it's
act together and provides Time Formatting for MS Access.
Enjoy,
Tom
------------------------------------------------------------------
// Time Format for CRYSTAL Reports (12:00 AM/PM format)
//
// Convert MS ACCESS Time to Whole Number
NumberVar TotWholeNbr:={Time.Time}*100000000;
// Calculate Hours
NumberVar Hours:=Truncate(TotWholeNbr/4166666.64);
// Calculate Minutes
NumberVar Mins:=Truncate((TotWholeNbr-(Hours*4166666.64))/69444.444);
// Set AM/PM String
If Hours>=12 Then
  StringVar AMPM:="PM";
If Hours<12 Then
  StringVar AMPM:="AM";
If Hours=0 then
  Hours:=12;
// If past 13:00, adjust hours
If Hours>12 Then
  Hours:=Hours-12;
// Set Hour String
If Hours<10 Then
  StringVar HH:="0"+ToText(Hours)
Else
  StringVar HH:=ToText(Hours);
// Set Minute String
If Mins<10 Then
  StringVar MM:="0"+ToText(Mins)
Else
  StringVar MM:=ToText(Mins);
// Output Time
HH[1 to 2]+":"+MM[1 to 2]+" "+AMPM[1 to 2];
------------------------------------------------------
// Time Format for CRYSTAL Reports (24:00 format)
//
// Convert MS ACCESS Time to Whole Number
NumberVar TotWholeNbr:={Time.Time}*100000000;
// Calculate Hours
NumberVar Hours:=Truncate(TotWholeNbr/4166666.64);
// Calculate Minutes
NumberVar Mins:=Truncate((TotWholeNbr-(Hours*4166666.64))/69444.444);
// Set Hour String
If Hours<10 Then
  StringVar HH:="0"+ToText(Hours)
Else
  StringVar HH:=ToText(Hours);
// Set Minute String
If Mins<10 Then
  StringVar MM:="0"+ToText(Mins)
Else
  StringVar MM:=ToText(Mins);
// Output Time
HH[1 to 2]+":"+MM[1 to 2];
---------------------------------------------------------------------
// Time Format for CRYSTAL Reports (24:00:00 format)
//
// Convert MS ACCESS Time to Whole Number
NumberVar TotWholeNbr:={Time.Time}*100000000;
// Calculate Hours
NumberVar Hours:=Truncate(TotWholeNbr/4166666.64);
// Calculate Minutes
NumberVar Mins:=Truncate((TotWholeNbr-(Hours*4166666.64))/69444.444);
// Calculate Seconds
NumberVar
Secs:=Truncate((TotWholeNbr-((Hours*4166666.64)+(Mins*69444.444)))/1157.4074
);
// Set Hour String
If Hours<10 Then
  StringVar HH:="0"+ToText(Hours)
Else
  StringVar HH:=ToText(Hours);
// Set Minute String
If Mins<10 Then
  StringVar MM:="0"+ToText(Mins)
Else
  StringVar MM:=ToText(Mins);
// Set Seconds String
If Secs<10 Then
  StringVar SS:="0"+ToText(Secs)
Else
  StringVar SS:=ToText(Secs);
// Output Time
HH[1 to 2]+":"+MM[1 to 2]+":"+SS[1 to 2];
--
Stefano Zamboni
----------------------------------------------------------------------------
----------------
sz...@XXXtin.it
zam...@XXXfreemail.it
Togliere "XXX" per rispondere
----------------------------------------------------------------------------
----------------