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!

Date Format

Status
Not open for further replies.

abdullauthan

Programmer
Apr 20, 2000
64
SA
How can I Get/Set the system date format specified in the Regional Settings under Control PAnel for ex: dd/MM/yyyy
 
Hi abdullauthan<br><br>&nbsp;U have an option of using a win32 api func. called<br>GetDateFormat().Following is the code for ur question.See if it helps.<br><br>&nbsp;<br>' Display today's date first in the default Long Date format and<br>' then in the standard HTTP date format.<br>Dim today As SYSTEMTIME&nbsp;&nbsp;' today's date and time<br>Dim datestr As String&nbsp;&nbsp;' receives the formatted date string<br>Dim strlen As Long&nbsp;&nbsp;' length of the buffer for the formatted date string<br><br>' Get today's date and time in the local time zone.<br>GetLocalTime today<br><br>' Make sufficient room in the buffer to receive the date string.<br>datestr = Space(255)<br>' Format today's date as a Long Date.<br>strlen = &lt;r&gt;GetDateFormat(0, DATE_LONGDATE, today, CLng(0), datestr, Len(datestr))&lt;/r&gt;<br>' Remove the empty space from the formatted date string.<br>datestr = Left(datestr, strlen)<br>' Display today's date as a Long Date.<br>Debug.Print &quot;Today is &quot;; datestr<br><br>' Now make sufficient room once again.<br>datestr = Space(255)<br>' Format today's date in the format used in HTTP.<br>strlen = GetDateFormat(0, 0, today, &quot;ddd',' dd MMM yyyy&quot;, datestr, Len(datestr))<br>' Remove the empty space from the formatted string.<br>datestr = Left(datestr, strlen)<br>' Display today's date in the HTTP-style format.<br>Debug.Print &quot;Today is &quot;; datestr<br><br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top