Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Stephen
 
Posts: n/a
Default formating a date field

I get the follow output from my datbase which is a date field.

7012005
12012005

I am trying to format it in 07/01/2005 fashion.
If I try to format it to a date stylein excel the dates do not convert
correctly. Any thoughts on how to get this format correctly.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave O
 
Posts: n/a
Default formating a date field

You can use the DATE() function in Excel along with some string parsing
functions to do this, but that 7012005 is going to be a bit tricky- in
a best case scenario that would come across as 07012005. The 8 digit
07012005 is easier because some month numbers have 1 digit and some
have 2, and pulling the month number out of that string is easier if
the number of columns is standard.

I suspect your database output is sending those fields as numerics, and
Excel is stripping off the leading zero.

Assuming your database output is in cell A1:
=IF(LEN(A1)=7,DATE(RIGHT(A1,4),MID(A1,1,1),MID(A1, 2,2)),DATE(RIGHT(A1,4),MID(A1,1,2),MID(A1,3,2)))

Format the formula cell for date, and copy down the column as necessary.

  #3   Report Post  
Posted to microsoft.public.excel.misc
Stephen
 
Posts: n/a
Default formating a date field

PERFECT!!!! THANK YOU!!!!

It works very well.

Thanks again.

"Dave O" wrote:

You can use the DATE() function in Excel along with some string parsing
functions to do this, but that 7012005 is going to be a bit tricky- in
a best case scenario that would come across as 07012005. The 8 digit
07012005 is easier because some month numbers have 1 digit and some
have 2, and pulling the month number out of that string is easier if
the number of columns is standard.

I suspect your database output is sending those fields as numerics, and
Excel is stripping off the leading zero.

Assuming your database output is in cell A1:
=IF(LEN(A1)=7,DATE(RIGHT(A1,4),MID(A1,1,1),MID(A1, 2,2)),DATE(RIGHT(A1,4),MID(A1,1,2),MID(A1,3,2)))

Format the formula cell for date, and copy down the column as necessary.


  #4   Report Post  
Posted to microsoft.public.excel.misc
daddylonglegs
 
Posts: n/a
Default formating a date field


You could also use this formula

=TEXT(A1,"00-00-0000")+0


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile: http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=503384

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Automatic, Non-Updating Date Stamp Ken Zenachon Excel Discussion (Misc queries) 8 January 18th 06 06:52 PM
Date & Time Field Diane Walker Excel Discussion (Misc queries) 2 January 10th 06 03:30 PM
Blank field formatted as date Emily8 Excel Worksheet Functions 5 October 11th 05 07:54 PM
in vba for access how do i get the day of the week for a date field? Daniel Excel Worksheet Functions 1 July 8th 05 12:57 AM
How to filter on a date field during mail merge SWADoug Excel Worksheet Functions 0 June 21st 05 06:31 PM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"