Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Convert a yyyymmdd date format in code

How does one in VBA code convert a date with format yyyymmdd (eg today's
date = 20110505) to a date recognized by Excel. I tried ConvertedDate =
Application.Worksheetfunction.Date(Left(InputDate, 4),Mid(Inputdate,5,2),Right(InputDate,2))
but that does not work. It would be easy enough in the spreadsheet, but in
VBA?
Thanks
Laurence



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Convert a yyyymmdd date format in code

Am Fri, 6 May 2011 08:50:33 +0200 schrieb Laurence Lombard:

How does one in VBA code convert a date with format yyyymmdd (eg today's
date = 20110505) to a date recognized by Excel. I tried ConvertedDate =
Application.Worksheetfunction.Date(Left(InputDate, 4),Mid(Inputdate,5,2),Right(InputDate,2))
but that does not work. It would be easy enough in the spreadsheet, but in


ConvertedDate =DateSerial(Left(Inputdate, 4), Mid(Inputdate, 5, 2), Right(Inputdate, 2))


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default Convert a yyyymmdd date format in code

On Fri, 6 May 2011 08:50:33 +0200, "Laurence Lombard" wrote:

How does one in VBA code convert a date with format yyyymmdd (eg today's
date = 20110505) to a date recognized by Excel. I tried ConvertedDate =
Application.Worksheetfunction.Date(Left(InputDate ,4),Mid(Inputdate,5,2),Right(InputDate,2))
but that does not work. It would be easy enough in the spreadsheet, but in
VBA?
Thanks
Laurence




Where "d" is a date in the format of yyyymmdd:


ConvertDate = CDate(Format(d, "0000-00-00"))

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Convert a yyyymmdd date format in code

Thanks Claus and Ron - both very useful replies. I knew there would be ways,
just did not know how to find them.
Laurence
"Ron Rosenfeld" wrote in message
...
On Fri, 6 May 2011 08:50:33 +0200, "Laurence Lombard"
wrote:

How does one in VBA code convert a date with format yyyymmdd (eg today's
date = 20110505) to a date recognized by Excel. I tried ConvertedDate =
Application.Worksheetfunction.Date(Left(InputDat e,4),Mid(Inputdate,5,2),Right(InputDate,2))
but that does not work. It would be easy enough in the spreadsheet, but in
VBA?
Thanks
Laurence




Where "d" is a date in the format of yyyymmdd:


ConvertDate = CDate(Format(d, "0000-00-00"))



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default Convert a yyyymmdd date format in code

On Sat, 7 May 2011 12:27:07 +0200, "Laurence Lombard" wrote:

Thanks Claus and Ron - both very useful replies. I knew there would be ways,
just did not know how to find them.
Laurence


Glad to help. Thanks for the feedback.
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
need to convert microsoft date to yyyymmdd pm Excel Discussion (Misc queries) 3 May 14th 23 11:43 AM
how do I convert date format yyyymmdd to mm/dd/yyyy Datahead Excel Worksheet Functions 3 May 11th 23 11:45 AM
How do I change date yyyymmdd to a Excel-supported date format? dan Excel Worksheet Functions 4 July 6th 08 11:05 PM
convert date (YYYYMMDD) to weeknumber mark paul Excel Worksheet Functions 1 February 27th 07 12:05 PM
yyyymmdd date format German Velasquez Excel Programming 11 November 30th 04 02:42 AM


All times are GMT +1. The time now is 07:23 PM.

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

About Us

"It's about Microsoft Excel"