Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Use Crystal built-in function to convert YYYYMMDD string to date

Posted on 2002-05-30
6
Medium Priority
?
5,164 Views
Last Modified: 2007-12-19
Is there an easier way to convert a string representation of dates in format 'YYYYMMDD' and 'YYYYMMDDHHMM' than using the trim functions?
0
Comment
Question by:bsumida
  • 4
  • 2
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 7045820
What are you trying to do?  DO you have date fields you are converting to strings?

mlmcc
0
 

Author Comment

by:bsumida
ID: 7046131
The database that I am using stores dates as string in the form: YYYYMMDD because it is much more efficient when searching.

I am using an ODBC connection to the back end and can only get the date info in this form which I must translate to a more conventional date format, for example, using VB's midstr() function, to cut up the string and reformat. I would like to bye pass this extra parsing step, if possible
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 200 total points
ID: 7047049
Not really but you can do the entire conversion in a CR formula

Something like
Change D to your DATE field

cdate (left(D,4) & "/" & mid(D,4,2) & "/" & right(D,2))

For the DATETIME

datetime (tonumber(left(DT,4)),tonumber(mid(DT,4,2)), tonumber(mid(DT,6,2)),tonumber(mid(DT,8,2)), tonumber(right(DT,2)),0)

DATETIME requires (YYYY,MM,DD,HH,MM,SS)  since you don't have the seconds I added the 0.  If you have seconds use

datetime (tonumber(left(DT,4)), tonumber(mid(DT,4,2)),  tonumber(mid(DT,6,2)), tonumber(mid(DT,8,2)), tonumber(mid(DT,10,2)), tonumber(right(DT,2)))

good luck
mlmcc
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
LVL 101

Expert Comment

by:mlmcc
ID: 7062537
Do you need any more help?

mlmcc
0
 

Author Comment

by:bsumida
ID: 7064700
Thanks mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7065244
glad to help

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview

927 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