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

Date and time problems

Status
Not open for further replies.

TomR100

Programmer
Aug 22, 2001
195
US
Hello,
I am creating a report from a SQL database where there is always an appointment date but not always an appointment time. The field I get this information from is called AppointmentDateTime and it cannot be spilt into Appointment Date and AppointmentTime.

Can someone help me with this formula to have the output 4/26 at 10:00AM or 4/26. Right now if I do not have a time I get no date.

Thank you in advance
 
I'll assume you mean SQL Server and that the data is stored as a datetime.

This should work as a formula:

if time({Testdate.Test}) > time(0,0,0)
then
totext(datepart("m",{Testdate.Test})) + "/" +
totext(datepart("d",{Testdate.Test})) +
" at " + totext(time({Testdate.Test}))
else
totext(datepart("m",{Testdate.Test})) + "/" +
totext(datepart("d",{Testdate.Test}))

Note that you cannot group/sort properly on this formula because it's text.

There are other ways of doing it.

-k kai@informeddatadecisions.com
 
synapsevampire,
The date is coming out like this:

5.00/13.00 at 6:00:00AM
Is there a way in Crystal to format this to come out as
05/13 at 6:00AM or if no time as 05/13

Thank you for your help
 
To get rid of the trailing '00', in your totext strings, end them with "00" just before you close the brackets.

i.e. totext({@time},"00")

<N>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top