BOB: Business Objects Board
Not endorsed by or affiliated with SAP

Register | Login 

 
Realtime CMS Reporting from Infolytik (Opens a new window)  

General Notice: No events within the next 45 days.

Convert date from string to date format


 
Search this topic... | Search Crystal Reports... | Search Box
Register or Login to Post    Forum Index -> Building Reports -> Crystal Reports  Previous TopicPrint TopicNext Topic
Author Message
pragathi
Forum Member
Forum Member



Joined: 12 Jul 2006

Posts: 17



PostPosted: Wed Aug 02, 2006 7:10 am 
Post subject: Convert date from string to date format

Hi,
I am using Crystal Report XI.I have a date in string format and want to convert it into date format..
when i use date(totext()) or cdate(totext()),m geting an error as bad date format...can anybody help..

Thanks in advance
Pragathi
Back to top
charlottecraig
Senior Member
Senior Member



Joined: 20 Jun 2006

Posts: 84



PostPosted: Wed Aug 02, 2006 1:47 pm 
Post subject: Re: Convert date from string to date format

It depends on the format of your date - this works cdate('07/28/2006') but you may need to use mid, left functions etc.. to pull it into a format where cdate will work
Back to top
LANFIELD
Principal Member
Principal Member



Joined: 18 May 2006
ASUG Icon
Posts: 463
Location: SIMI VALLEY, CA


flag
PostPosted: Sat Aug 05, 2006 10:34 pm 
Post subject: Re: Convert date from string to date format

datevalue(yyy/mm/dd) also works as well as datetimevalue()
Back to top
pragathi
Forum Member
Forum Member



Joined: 12 Jul 2006

Posts: 17



PostPosted: Mon Aug 07, 2006 5:26 am 
Post subject: Re: Convert date from string to date format

Thanks...
Back to top
WizardofCR
Forum Member
Forum Member



Joined: 10 Aug 2006

Posts: 9



PostPosted: Thu Aug 10, 2006 1:45 am 
Post subject: Re: Convert date from string to date format

You also can use the date function too... as below

Example... ORDERS table has an ORDER_DATE field, that store date as string in YYMMDD format. eg. 060810 for 10/08/06.

To convert this data to date value I use the below formula......

stringvar yyear;
stringvar mmonth;
stringvar dday;

dday := {ORDERS.ORDER_DATE}[5 to 6];
mmonth := {ORDERS.ORDER_DATE}[3 to 4];
yyear := {ORDERS.ORDER_DATE}[1 to 2];

if yyear < "50" then
date(tonumber(yyear)+2000,tonumber(mmonth),tonumber(dday))
else
date(tonumber(yyear)+1900,tonumber(mmonth),tonumber(dday))


This's working wonder....
Back to top
leelondon
Forum Member
Forum Member



Joined: 10 Jun 2010

Posts: 1



PostPosted: Thu Jun 10, 2010 6:01 am 
Post subject: Re: Convert date from string to date format

beautiful Wizard thanks..
Back to top
neison
Forum Member
Forum Member



Joined: 29 Oct 2010

Posts: 1



PostPosted: Fri Oct 29, 2010 1:46 pm 
Post subject: Re: Convert date from string to date format

Please help Im using crystal 2008 and Im trying to convert dates (format yyyy-mm-dd) my formula is INT (( current date - date ({field name})) / 365.25) but I get a bad date format error Ive tried everything can someone help?
Back to top
Display posts from previous:   
Register or Login to Post    Forum Index -> Building Reports -> Crystal Reports  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 5 Hours
 
Jump to:  

Index | About | FAQ | RAG | Privacy | Search |  Register |  Login 

Get community updates via Twitter:

Not endorsed by or affiliated with SAP
Powered by phpBB © phpBB Group
Generated in 0.0449 seconds using 17 queries. (SQL 0.0019 Parse 0.0353 Other 0.0077)
CCBot/2.0 (http://commoncrawl.org/faq/)
Hosted by ForumTopics.com | Terms of Service
phpBB Customizations by the phpBBDoctor.com
Shameless plug for MomentsOfLight.com Moments of Light Logo