Print Page | Close Window

Adding : to a string (every 2 characters)

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=13092
Printed Date: 02 May 2024 at 10:42pm


Topic: Adding : to a string (every 2 characters)
Posted By: andrew
Subject: Adding : to a string (every 2 characters)
Date Posted: 03 May 2011 at 5:21am
Hi all,

I'm working on a report to catalog tapes coming into a TV station.

The timecodes are stored in the database as a string (00000000)

For the operators to read it properly, I need to add : in every 2 characters so it splits the string as:

00:00:00:00 (Hours, Minutes, Seconds, Frames).

Is there  a pre-existing function that can do this, or is the best way to create an array and then create a new string that adds the array together along with..

& ":" & ?

Many thanks!

Andrew



Replies:
Posted By: hilfy
Date Posted: 03 May 2011 at 10:43am
Try this (Crystal syntax):
 
Left({table.field}, 2) + ':' + mid({table.field}, 3, 2) + ':' + mid({table.field}, 5, 2) + ':' + right({table.field}, 2)
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: andrew
Date Posted: 04 May 2011 at 10:41pm
Hi Hilfy - thank you so much, that code works great!



Print Page | Close Window