![]() |
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 |
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 |
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")) |
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")) |
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. |
All times are GMT +1. The time now is 10:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com