Solved

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

Posted on 2002-05-30
6
4,245 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 100

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 100

Accepted Solution

by:
mlmcc earned 50 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 100

Expert Comment

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

mlmcc
0
 

Author Comment

by:bsumida
ID: 7064700
Thanks mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 7065244
glad to help

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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 …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now