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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date format using = FormatDateTime(Now, vbGeneralDate)

Status
Not open for further replies.

alchohaz

Technical User
Mar 25, 2004
216
GB
Hi there hopefully this will be a simple one :)

I have the following line of Code:

Code:
    Range("Completed").Value = FormatDateTime(Now, vbGeneralDate)

It sets a time and date stamp to CELL Named "Completed" - last week this working fine, but this week, strangley the date has changed to the US Standard.

Example:

Todays date is stamped as 11/02/10 etc when i would expect it to be 02/11/10 etc - Is this set in the code or the APP Settings itself?

Thanks in advance

Al



 
Why storing a text value for a date ?
Range("Completed").Value = Date

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



Check out faq68-5827

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

Thank for your comments - neithet have addressed my issue. The Code i have used was working fine until some point last week, and now it's gone all "US standard" on me. I don't want to change the code really, and i have checked the regional settings and they seem OK.

 
So, what about this ?
Range("Completed").Value = Format(Now, "dd/mm/yy")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

Thanks PHV - that will work on my code but i want the hours mins and seconds too, i am guesing i can just add that as if it were a custom date/time - i will have a play to resolve that.

However it doesn't fix my overall problem which is also reflected when i enter a date using a form i have created.

Example when i enter 08/11/10 in the form, it is resolved in the sheet as 11/08/10 (August rather than November). I am assuming the two issues (The Form in put and the vbGeneralDate) are related, Regional Setting seems the obvious choice, but problem is not apparent when i checked that area.

 

Something very suspect happening here - i changed the regional settings to US and ran the Macro - this resulted in the correct information being displayed !! I changed it back to UK setting ran the macro again and they are now incorrect !!

Any tips please ?

 



Post the macro code.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

Code is as above in the following context:

Code:
If Application.Dialogs(xlDialogSendMail).Show("abc.t.com  ", Subject) = True Then
    Range("Completed").Value = FormatDateTime(Now, vbGeneralDate) 

End If

But i have now managed to get it to work as follows:
Code:
If Application.Dialogs(xlDialogSendMail).Show("abc.t.com  ", Subject) = True Then
    Range("PM_APP").Value = Format(Now, "DD/MMM/YYYY HH:MM:SS")
End If


    Range("PM_APP").Select
    Selection.NumberFormat = "dd/mm/yyyy hh:mm:ss"

However the original issue still remains, i have just worked around it.


 


You have not read my FAQ!

You have assigned a STRING to Range("PM_APP"), not a DATE!

Code:
If Application.Dialogs(xlDialogSendMail).Show("abc.t.com  ", Subject) = True Then
    With Range("PM_APP")
        .Value = Now
        .NumberFormat = "dd/mm/yyyy hh:mm:ss"
    End with
End If



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

Skip i did, but to me as a novice this was not clear - thanks for your input, it is always appreciated.

In my defence what i was actually after was the cause of the issue - this was working last week (as Value = FormatDateTime(Now, vbGeneralDate) and now for some unknown reason it has changed to the US Format with no rhyme or reason.

On that particular foible it loks like i won't find out the reason (if there is one) - but thank you all for your input anyway - am taking on board all of the tips and tricks as i go along

cheers
Al

:)

 


Did it work for you?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top