Solved

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

Posted on 2002-05-30
6
4,721 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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