Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
formatting dates
Just when I thought I had formatting dates in VBA under control, I
obtained a new PC with Excel 2003 SP2 and a program which used to work perfectly now gives an error with formatting dates. Basically I read a date from a listboxbut if the date is blank, I set it to a default of 01/01/1901 The relevant bits of code are Dim sDate As Date Dim stDate As Long If formInput.ListBox2.Value = "date_entered" Then sDate = formInput.TextBox3.Value Else sDate = "01/01/1901" End If stDate = Right(sDate, 4) & Mid(sDate, 4, 2) & Left(sDate, 2) As I said, this worked ok under a previous version of excel and if sdate was set to 01/01/1901, stdate correctly became 19010101. Now even tho sDate is set to "01/01/1901", excel treats it as "1/01/1901" and consquently stdate is either not evaluated or evaluated incorrectly. Can someone please tell me how to overcome this? I need to finish up with stdate in the form 20051201 (yyyymmdd) after reading a date from a form )in the format dd/mm/yyyy or dd/mm/yy. Thanks Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting Dates | Excel Discussion (Misc queries) | |||
Formatting Dates | Excel Discussion (Misc queries) | |||
Dates Not Formatting as Dates | Excel Worksheet Functions | |||
Formatting dates | Excel Worksheet Functions | |||
Formatting Dates | Excel Programming |