Solved

convert number to date

Posted on 2013-12-13
8
943 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
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 demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

830 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