Solved

convert number to date

Posted on 2013-12-13
8
908 Views
Last Modified: 2013-12-13
i am tapping into an excel sheet as my database source.  I have a settlement date column that is in MM/DD/YY format but when its pulled down into crystal reports it shows the date serial instead of the date format...and crystal thinks its a number so its not letting me change formatting to date.  So I figure I could just use a formula field to convert the number to date format...i know you can do this with string, but how about numbers?

for string i know you can do the following:
date(tonumber(left({table.datestring},4)),tonumber(mid({table.datestring},5,2)),tonumber(right({table.datestring},2)))

how can I work this for numbers to date?
0
Comment
Question by:IO_Dork
8 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 39717478
Have you tried:

 Format(tonumber,"mm/dd/yy")

Flyster
0
 

Author Comment

by:IO_Dork
ID: 39717502
no i have not, how is that incorporated/used?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39717515
WHat is it showing in Crystal?
Can you give an example?

mlmcc
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:IO_Dork
ID: 39717533
in excel the date is 7/9/97, in cyrstal that same date is displayed as 35,620.00
0
 

Expert Comment

by:richlando
ID: 39717544
stringvar stryear;
stringvar strmonth;
stringvar strday;

strday:= {table.datestring}[5 to 6];
strmonth:= {table.datestring}[3 to 4];
stryear:= {table.datestring}[1 to 2];

if yyear < "50" then
date(tonumber(stryear)+2000,tonumber(strmonth),tonumber(stryear))
else
date(tonumber(stryear)+1900,tonumber(strmonth),tonumber(stryear))
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39717546
That looks like the number of days since 31 Dec 1899

Try this formula

DateSerial(1899,12,{YourField}+30)

Another one is

DateAdd('d',{YourField},Date(1899,12,31))

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39717550
richlando - The field is a number not a string.

mlmcc
0
 

Author Closing Comment

by:IO_Dork
ID: 39717605
that worked perfectly (the first dateserial formula you suggested).
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from 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.

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 …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

776 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