Link to home
Start Free TrialLog in
Avatar of krs_rama
krs_rama

asked on

Find the Current Date format of the Machine From Bas Module

I am trying to get the current date format of the machine i work. But i could not succeed in getting this by using the GetDateformat Api. Kindly give me solution to find the current system's date format (Whether or not the format is "MM-DD-YYYY" ). If possible send the soulution so that i can get the current date format of the machine.
Regards
krs Rama
ASKER CERTIFIED SOLUTION
Avatar of angel71
angel71

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GeoffKell
GeoffKell

The API route to do this is using GetLocaleInfo call as follows

regards
GK

Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

Private Const LOCALE_SSHORTDATE = &H1F

Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long


Private Function SystemDateFormat() As String
    Dim lngLocale As Long
    Dim strFormat As String
    Dim lngLength As Long

    lngLocale = GetSystemDefaultLCID()
    lngLength = 100
    strFormat = Space$(lngLength)

    Call GetLocaleInfo(lngLocale, LOCALE_SSHORTDATE, strFormat, lngLength)
   
    SystemDateFormat = Trim$(strFormat)

End Function
angel71 - Please read the comments at the bottom of the page regarding the use of comments and proposing answers.

The question asks "how to get the date format of a machine". You have proposed an answer that shows how to get the current time and format it in whatever format you require.

Regards
GK
Avatar of Richie_Simonetti
GK has the real solution.
Avatar of krs_rama

ASKER

geoffkell answer is perfect !!!
krs_rama - You confuse me.

"GeoffKell answer is perfect !!!"

So you award the points with a 'C' grade to angel71 who didn't even answer the correct question.

Ho Hum

GK
What a mess ;)
Yes what a mess Geofkell I'm really sorry... Is there a way to fix this?
Yes what a mess Geofkell I'm really sorry... Is there a way to fix this?
No problem.

I've posted a link to it community support. It's up to them now

Regards
GK
Looking at it.

costello
Community Support Moderator  @ Experts Exchange
I have reduced the points of this question to 0, but can't reverse the accepted answer here.

I'll be opening a new 100 points question for GeoffKell in the VB section.

costello
Community Support Moderator  @ Experts Exchange