Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-05-30
6
Medium Priority
?
4,920 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 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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
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

[Webinar] Protection from Cyberattacks

In this session, we’ll dive into the complexities of modern cyber threats and why only multi-vector protection can keep today’s businesses secure through the various stages of a cyberattack, across multiple vectors. Thursday September 14, 2017 10:00 A.M. PDT

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 …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

730 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