Click to See Complete Forum and Search --> : FormatDateTime


Alv
05-29-2003, 02:44 AM
If I am not mistaken, FormatDateTime uses the setting specified in the regional settings. I have already set my regional setting to display short date in this format (e.g 06-May-03) but ASP FormatDateTime(x, 2) returns 05/06/2003 where x is the date.

This happen erratically on a NT 4 SP 6 and XP Pro SP 1 box, which means sometimes ASP display the date correctly and sometimes they don't. Anyone has any idea what actually cause this? Any way to resolve this problem?

Thanks in advance.

Ribeyed
05-29-2003, 03:02 AM
hi,
you can try here:
http://www.learnasp.com/learn/datetime.asp

cmelnick
05-29-2003, 10:24 AM
If it is on server side, and you want to force it to display DD-MM-YYYY, then use the following:


<%

Dim currDate, formattedDate
currDate = Now()

formattedDate = Day(currDate) & "-" & _
MonthName(Month(currDate), True) & "-" & _
Year(currDate)

%>

<%=formattedDate%>

Alv
05-29-2003, 11:10 PM
All scripts are ran server side. So by default, FormatDateTime should be using the format stipulated in the Regional Settings which in my case, sometimes it does and sometime it doesn't.
Alternating between 06-May-03 (Regional Settings) and 05/06/2003.

Suggestion from cmelnick definitely would produce the results I want but I would also love to understand why the function return such erratic result. If the FormatDateTime function perform as it should be, I do not need to cut the date using Day, MonthName and Year functions.

I suspect something amiss here. Either some setting on the server, or IIS or even the script itself cause the behavior of the FormatDateTime function which I might have overlook.

Alv
05-30-2003, 11:03 PM
The site runs on a single server. That is why it has me stumped. The weird thing is if it happen, I'll have to shut (stop) the site down via IIS then reboot. After that, it'll be okay.

Its pretty annoying having to reboot every other day. :)

Alv
06-10-2003, 08:30 PM
Any update on this guys?

Thanks in advance.

Ribeyed
06-10-2003, 08:51 PM
hi,
try this, it worked for me :)

mydatetime = FormatDateTime(Date, VBLongDate)