?
Solved

CTime({ado.x}) returning "12:00 AM" for all {ado.x}

Posted on 2004-11-11
9
Medium Priority
?
372 Views
Last Modified: 2012-06-21
CTime({ado.x}) returning "12:00 AM" for all {ado.x}.  The CTime function takes number or string arguments.  My argument is an integer that can range from 0 to 2399.  No matter what the integer value, CTime is returning "12:00 AM"!  This doesn't do what I think it should do.  All I want is for it to return the time on a 12-hour clock.

By the way...

I checked Format Field and the sample at the bottom of the Date/Time tab is the correct time format I desire.  

I've tried CTime(CStr({ado.x})) and get a bad time format string.

I've also IsTime({ado.x}) and it's returned True.  

So what gives???  Please help.
0
Comment
Question by:MariaHalt
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12557161
Where are you using this function?

What version of Crystal?

mlmcc
0
 

Author Comment

by:MariaHalt
ID: 12557173
In a formula in my Crystal report.  Version 8.5.
0
 
LVL 4

Expert Comment

by:gusdarino
ID: 12557308
Can you provide some sample values for {ado.x}?  

GusDarino
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 

Author Comment

by:MariaHalt
ID: 12557344
They range from 0 to 2359.  Like, 930, 1100, 1415, 2130.
0
 
LVL 28

Accepted Solution

by:
bdreed35 earned 150 total points
ID: 12557525
Try this:

CTime(int({ado.x}/100),remainder({ado.x},100),0)
0
 

Author Comment

by:MariaHalt
ID: 12557575
Perfect!
0
 
LVL 4

Expert Comment

by:gusdarino
ID: 12557694
OK that makes more sense now.  You originally listed 0 to 2359.

I am assuming then that:

930 = 9:30 am
1100 = 11:00 am
1415 = 2:15 pm
2130 = 9:30 pm

I assume that whole hours such as 1:00 pm are listed as 1300 and 9:00 am as 900.
The integer stores time in military format with hours and minutes only.

If my assumptions are correct then you can do the following:
Create a formula as follows:
if len(totext({Ado.x})) = 4 then TimeSerial(0,(tonumber(right(totext({Ado.x}),2))),(tonumber(left(totext({Ado.x}),2))*3600)) else
if len(totext({Ado.x})) = 3 then TimeSerial(0,(tonumber(right(totext({Ado.x}),2))),(tonumber(left(totext({Ado.x}),1))*3600)) else
if len(totext({Ado.x})) = 2 then TimeSerial(0,{Ado.x},0) else
TimeSerial(0,0,({Ado.x}*3600))

Put the formula in the report and it should give you what you are looking for.  I am sure there are other ways of getting the same results.  This is just what came to mind.

GusDarino
0
 

Author Comment

by:MariaHalt
ID: 12557730
Your assumptions are correct.  And I did mistakenly say 2399 instead of 2359 in my original post.  I've accepted bdreed35's answer.  Thanks.
0
 
LVL 4

Expert Comment

by:gusdarino
ID: 12557758
NP, I did not refresh my browser before posting.  :-)  His answer is much better.

GusDarino
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question