ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date format (https://www.excelbanter.com/excel-programming/344195-date-format.html)

Jos Vens[_2_]

Date format
 
Hi,

how can I know what the default date and time format is set on the user's
computer. Now I set it to a special format (yy-mm-dd) but the user asks to
let it be like his computer's setting.

Thanks
Jos Vens



Tom Ogilvy

Date format
 
If you just put a date in an unformatted cell, it should use the default
date

activecell.Value = Date
? activeCell.NumberFormat
m/d/yy
ActiveCell.Offset(1,0).Value = Time
? activeCell.Offset(1,0).Numberformat
h:mm:ss AM/PM


--
Regards,
Tom Ogilvy



"Jos Vens" wrote in message
...
Hi,

how can I know what the default date and time format is set on the user's
computer. Now I set it to a special format (yy-mm-dd) but the user asks to
let it be like his computer's setting.

Thanks
Jos Vens





Jos Vens[_2_]

Date format
 
Thanks Tom,

but: if i use your code, I get 05-10-29 in my cell (my systemsetting is
jj-MM-dd)
but ?activecell.numberformat gives me "m/d/yyyy", which is not my
systemsetting.

Can you still help me?
Jos


"Tom Ogilvy" schreef in bericht
...
If you just put a date in an unformatted cell, it should use the default
date

activecell.Value = Date
? activeCell.NumberFormat
m/d/yy
ActiveCell.Offset(1,0).Value = Time
? activeCell.Offset(1,0).Numberformat
h:mm:ss AM/PM


--
Regards,
Tom Ogilvy



"Jos Vens" wrote in message
...
Hi,

how can I know what the default date and time format is set on the user's
computer. Now I set it to a special format (yy-mm-dd) but the user asks
to
let it be like his computer's setting.

Thanks
Jos Vens







Bob Phillips[_6_]

Date format
 
Jens,

Try NumberFormatLocal instead.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jos Vens" wrote in message
...
Thanks Tom,

but: if i use your code, I get 05-10-29 in my cell (my systemsetting is
jj-MM-dd)
but ?activecell.numberformat gives me "m/d/yyyy", which is not my
systemsetting.

Can you still help me?
Jos


"Tom Ogilvy" schreef in bericht
...
If you just put a date in an unformatted cell, it should use the default
date

activecell.Value = Date
? activeCell.NumberFormat
m/d/yy
ActiveCell.Offset(1,0).Value = Time
? activeCell.Offset(1,0).Numberformat
h:mm:ss AM/PM


--
Regards,
Tom Ogilvy



"Jos Vens" wrote in message
...
Hi,

how can I know what the default date and time format is set on the

user's
computer. Now I set it to a special format (yy-mm-dd) but the user asks
to
let it be like his computer's setting.

Thanks
Jos Vens









Bob Phillips[_6_]

Date format
 
Jos,

Apologies for the wrong name, I was watching Jens Lehmann on the TV

Bob


"Bob Phillips" wrote in message
...
Jens,

Try NumberFormatLocal instead.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jos Vens" wrote in message
...
Thanks Tom,

but: if i use your code, I get 05-10-29 in my cell (my systemsetting is
jj-MM-dd)
but ?activecell.numberformat gives me "m/d/yyyy", which is not my
systemsetting.

Can you still help me?
Jos


"Tom Ogilvy" schreef in bericht
...
If you just put a date in an unformatted cell, it should use the

default
date

activecell.Value = Date
? activeCell.NumberFormat
m/d/yy
ActiveCell.Offset(1,0).Value = Time
? activeCell.Offset(1,0).Numberformat
h:mm:ss AM/PM


--
Regards,
Tom Ogilvy



"Jos Vens" wrote in message
...
Hi,

how can I know what the default date and time format is set on the

user's
computer. Now I set it to a special format (yy-mm-dd) but the user

asks
to
let it be like his computer's setting.

Thanks
Jos Vens











Norman Jones

Date format
 
Hi Jens,

Try:
'=================
Function SettingVaL(strSetting As String)
Dim strComputer As String
Dim strKeyPath As String
Dim strEntryName As Variant
Dim strValue As String
Dim strLogFile As String
Dim objReg As Object
Dim objFSO As Object
Dim arrValue, byteValue, arrEntryNames, arrValueTypes


Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_USER = &H80000001
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7


strKeyPath = ".DEFAULT\Control Panel\International"
strLogFile = "C:\RegionalSettings.txt"


Set objFSO = CreateObject("Scripting.FileSystemObject")
''Set objLogFile = objFSO.CreateTextFile(strLogFile)
'''objLogFile.Writeline ("This logfile was made on " _
& Date & " at " & Time & "." & VbCrLf )

strComputer = "."

' Connect to the WMI Regisitry-provider
Set objReg = GetObject("winmgmts:{impersonationLevel" _
& "=impersonate}!\\" & strComputer _
& "\root\default:StdRegProv")

objReg.EnumValues HKEY_USERS, strKeyPath, _
arrEntryNames, arrValueTypes
For Each strEntryName In arrEntryNames
'*** This is the only Binary value
If strEntryName = "DefaultBlindDialFlag" Then
objReg.GetBinaryValue HKEY_USERS, strKeyPath, _
strEntryName, arrValue

For Each byteValue In arrValue
If strEntryName = "s" & strSetting Then
SettingVaL = strValue
Exit Function
End If
Next
Else
'*** These are all RegSZ value's
objReg.GetStringValue HKEY_USERS, strKeyPath, _
strEntryName, strValue
If strEntryName = "s" & strSetting Then
SettingVaL = strValue
Exit Function
End If

End If
Next

End Function
'<<=================

'=================
Sub GetDateFormat()
Dim ShortDt As String
Dim LongDt As String

ShortDt = SettingVaL("ShortDate")
LongDt = SettingVaL("LongDate")

MsgBox ShortDt & vbNewLine & LongDt
End Sub
'<<=================

---
Regards,
Norman



"Jos Vens" wrote in message
...
Thanks Tom,

but: if i use your code, I get 05-10-29 in my cell (my systemsetting is
jj-MM-dd)
but ?activecell.numberformat gives me "m/d/yyyy", which is not my
systemsetting.

Can you still help me?
Jos


"Tom Ogilvy" schreef in bericht
...
If you just put a date in an unformatted cell, it should use the default
date

activecell.Value = Date
? activeCell.NumberFormat
m/d/yy
ActiveCell.Offset(1,0).Value = Time
? activeCell.Offset(1,0).Numberformat
h:mm:ss AM/PM


--
Regards,
Tom Ogilvy



"Jos Vens" wrote in message
...
Hi,

how can I know what the default date and time format is set on the
user's
computer. Now I set it to a special format (yy-mm-dd) but the user asks
to
let it be like his computer's setting.

Thanks
Jos Vens









Jos Vens[_2_]

Date format
 
Thanks Bob,

it is really what I'm looking for

Thanks Norman for your code I may use later maybe,

Greetings
Jos


"Bob Phillips" schreef in bericht
...
Jens,

Try NumberFormatLocal instead.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jos Vens" wrote in message
...
Thanks Tom,

but: if i use your code, I get 05-10-29 in my cell (my systemsetting is
jj-MM-dd)
but ?activecell.numberformat gives me "m/d/yyyy", which is not my
systemsetting.

Can you still help me?
Jos


"Tom Ogilvy" schreef in bericht
...
If you just put a date in an unformatted cell, it should use the
default
date

activecell.Value = Date
? activeCell.NumberFormat
m/d/yy
ActiveCell.Offset(1,0).Value = Time
? activeCell.Offset(1,0).Numberformat
h:mm:ss AM/PM


--
Regards,
Tom Ogilvy



"Jos Vens" wrote in message
...
Hi,

how can I know what the default date and time format is set on the

user's
computer. Now I set it to a special format (yy-mm-dd) but the user
asks
to
let it be like his computer's setting.

Thanks
Jos Vens












All times are GMT +1. The time now is 06:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com