Date format in ASP

G

Giorgio Cervati

Hi,
is there a way to 'force' ASP date function to return date in a given
format; I mean, my need is to force 'date()' function to give me system date
in italian format instead of english (O.S. is in english as well as locale
settings for IIS anonymous user); is there a directive or something similar
to put in ASP code?

Tnx in advance.

Giorgio
 
K

Ken Schaefer

You can set Session.LCID (or LCID in your @ directives)

Check out:
http://support.microsoft.com/?id=229690

Cheers
Ken


: Hi,
: is there a way to 'force' ASP date function to return date in a given
: format; I mean, my need is to force 'date()' function to give me system
date
: in italian format instead of english (O.S. is in english as well as locale
: settings for IIS anonymous user); is there a directive or something
similar
: to put in ASP code?
:
: Tnx in advance.
:
: Giorgio
:
:
 
B

Bullschmidt

This is a little different approach but to make a variable be in the
format of mm/dd/yyyy (and the final line of code can be modifed for
other date formats), perhaps try something like the following which you
might even make into a function:

varFld = CDate(MyVariable)

intMonth = Month(varFld)
intDay = Day(varFld)
intYr = Year(varFld)

If intMonth < 10 Then
strMonth = "0" & CStr(intMonth)
Else
strMonth = CStr(intMonth)
End If

If intDay < 10 Then
strDay = "0" & CStr(intDay)
Else
strDay = CStr(intDay)
End If

strYr = Right(CStr(intYr), 4) ' And change the 4 to 2 for 2 year dates.

varFld = CStr(strMonth & "/" & strDay & "/" & strYr)

Best regards,
J. Paul Schmidt, Freelance ASP Web Consultant
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 
D

dlbjr

'from dlbjr

Function FormatMyDate(dtmDate)
FormatMyDate = "NAD"
If IsDate(dtmDate) Then
Dim arData(2)
arData(0 = Right("00" & Month(dtmDate),2)
arData(1) = Right("00" & Day(dtmDate),2)
arData(2) = Year(dtmDate)
FormatMyDate = Join(arData,"/")
End If
End Function
 
G

Giorgio Cervati

Well, my problem was to make my asp application 'o.s. independent'. I
mean some security patches changed IUSR anonymous user locale settings
so my application began to read date and currencies in a different way.
The way you act is quite good but it doesn't remove the basis of the
problem while the Session.LCID method does.

Many thanks.

G.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top