?
Solved

Excel query to convert date format

Posted on 2011-02-19
3
Medium Priority
?
1,063 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
[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
3 Comments
 
LVL 39

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 1000 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:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 1000 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

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.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
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 on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

765 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