Solved

Excel query to convert date format

Posted on 2011-02-19
3
1,056 Views
Last Modified: 2012-05-11
I have an excel query that returns data from my Pervasive db. However the date format is not recognized as a date by excel. How can I convert the date format so that it is recognized by excel. I would prefer to have it converted with the query statement but if that can't be done I would have to convert it once it is returned to excel.
Here is the date format it returns:
YYYYMMDD
so Feb 19 2011 is shown as 20110219
0
Comment
Question by:RTsal
3 Comments
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 34933319
If you can get it to yyyy-mm-dd excel will recognize it.
0
 
LVL 18

Assisted Solution

by:mirtheil
mirtheil earned 250 total points
ID: 34933353
From a Pervasive perspective, that doesn't seem like a data field because PSQL keeps the format as yyyy-mm-dd.  You can convert it to that format in a PSQL query with something like:
select left(f1, 4) + '-' + substring(f1,4,2) + '-' + right(f1,2) from table
You can even convert that to a Date data type with the following:
select CONVERT (left(f1, 4) + '-' + substring(f1,4,2) + '-' + right(f1,2), SQL_DATE) from table
0
 
LVL 50

Accepted Solution

by:
teylyn earned 250 total points
ID: 34935814
Hello,

You can use several techniques in Excel to convert this to a date.

Method 1:

Select the column with the dates, then click Data > Text to Columns > Fixed Width. Click Next and in the "Column Data Format" area select Date and use the dropdown to set it to YMD. Then click Finish.


Method 2:

Use a helper column with the formula (assuming your "date" values are in column A, starting in row 1)

=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))

Copy the formula down all rows.

Copy the results of the helper column and use Paste Special > Values to paste them over the original data, then delete the helper column.

cheers, teylyn

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now