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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data format with AM/PM

Status
Not open for further replies.

bandarna

Programmer
Jan 2, 2003
122
US
I am new to crystal reports.
I have created a report on Oracle VIEW. My view has varchar2 field holds date with YY/MM/DD HH24:SS AM format.

When I select like this in SQL prompt

Select f2date from <viewname>;

I got like this 05/19/03 06:31 AM this is fine. I just want same on my report.

But my report is showing only 05/19/03 06:31. no AM/PM. How can I display AM/PM. Do I need to create a formula? If so what is the code.

 
Since a varchar2 isn't a date, you wouldn't think that even Oracle would know to place a time indicator on it without a CAST or some such.

And it's returning a datetime without the seconds from what you displayed.

Consider creating a SQL Expression to convert it to a real datetime, or a formula within Crystal, as in:

@realdate
cdatetime({table.field})

Now use this in your report, if it isn't formatted the way you like: right click it and select format field->Date/Time->Customize and set the attributes to suit your needs.

-k
 
I would highly recommend changing the view to return the date format exactly how you want it. Or even have the view create an additional text field with the date in the format you want it. Otherwise your only option is to use the ToText function within Crystal and create a if and then formula to check the time portion of the date field and convert the date to text and then add either a AM/PM to the end of the text.
 
Not true, they can also use a SQL Expression, which passes the function in the SQL, which is almost the same.

The solution I offered works just fine within a formula, and it converts it to a datetime, which allows for right clicking and changing the formatting to include AM/PM without any code.

Test it.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top