Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrong Date Format in Excel? 4

Status
Not open for further replies.

yalamo

Technical User
Sep 22, 2002
244
IL
While trying to input some date variables in an Excel 2000 VBA subroutine, I ran into a curious problem:

My default short date format (according to the Regional and Language Options in the Win XP Control Panel) is dd/mm/yyyy, so that 2 October 2005 should be 02/10/2005, which is the way I want it.

However, I found that 2/10/5 was showing up as 10/02/2005, the way it is in the U.S. But if I input 13/9/5 in the VBA UserForm, it would show up as 13/09/2005 in the Excel spreadsheet, which is correct, as far as I'm concerned. Apparently, if the day of the month is 12 or less, Excel assumes you mean the U.S. format. More than 12, and it decides to use the European forman

I did a workaround by using an If..Then..Else statement, but I find this pretty annoying. Is there a bug in Excel date formats?
 
Hi

Code:
deadlinetime = Right(txtDeadline, 5)
    Cells(srow, 5) = DateValue(frmCheckers.txtDeadline.Text) & " " & deadlinetime

I have just got this to work for me. But if anyone has any other ideas.

PS what is implicit adding?

Regards

David

 
Sorry posted my reply before I read your replies.



Regards

David

 
'perhaps implicit adding isnt the right way of saying it :)


'from MS

DateAdd(interval, number, date)

The DateAdd function syntax has these named arguments:

Part Description
interval Required. String expression that is the interval of time you want to add.
number Required. Numeric expression that is the number of intervals you want to add. It can be positive (to get dates in the future) or negative (to get dates in the past).
date Required. Variant (Date) or literal representing date to which the interval is added.



Settings

The interval argument has these settings:

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top