Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Date Field via VB, CR9 1

Status
Not open for further replies.

agersh

Programmer
May 8, 2003
12
US
Using VB6 and Crystal Reports 9 the users have the ability to create ad-hoc reports.

My problem is that when a date field is selected/in the report, the field is displayed in the report with the date plus a time. I only want to show the date portion only. Using crystals Field Object properties how can I format the field so that it only displays the date portion?
 
You can try the following:

Go to File > Report Options > Convert Date time field > Select Date from the drop down list.

Save the changes.

Kchaudhry
 
In 8.5, you have the option to convert DateTime data to a Date, a String, or leave it alone at runtime by setting the ConvertDateTimeType property of the Report object:

Report.ConvertDateTimeType = crConvertDateTimeToDate
Report.ConvertDateTimeType = crConvertDateTimeToString
Report.ConvertDateTimeType = crKeepDateTimeType

Works for me, and I just checked the 9.0 RDC Object Model, and it's still there.

-dave
 
vidru,

Thanks for your reply it worked fine. I do seem to have another formatting problem regarding displaying dates. The date is displaying as "9/6/2001" I need to format it as "09/06/2001". Any Ideas?

agersh
 
agersh,

You can go with your original idea, and use the FieldObject to set it. That way, you can also control the formatting.

You can loop through ReportObjects collection to find the FieldObjects, then set the date/time properties however you want. Here's an example that will result in a MM/DD/YYYY date format:
[tt]
crxFieldObject.DayType = crLeadingZeroNumericDay
crxFieldObject.MonthType = crLeadingZeroNumericMonth
crxFieldObject.YearType = crLongYear
crxFieldObject.HourType = crNoHour
crxFieldObject.MinuteType = crNoMinute
crxFieldObject.SecondType = crNumericNoSecond
crxFieldObject.AmString = ""
crxFieldObject.PmString = ""
[/tt]

-dave
 
vidru, Thanks again for all your help, you are the best.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top