how to set correct date format

H

Himanshu Dora

Hi
I have set with lcid value. but i am not able to overcome my nt server
regional setting. Actually i want a date in mm/dd/yyyy. But i get date as
mm/dd/yy. How to ensure that i shall always get correct format irrespective
of os or regional setting.

regards
himanshu
 
B

Bob Barrows

Himanshu said:
Hi
I have set with lcid value. but i am not able to overcome my nt
server regional setting. Actually i want a date in mm/dd/yyyy. But i
get date as mm/dd/yy. How to ensure that i shall always get correct
format irrespective of os or regional setting.

Convert the date to a string with the proper format using the various date
functions available: day(), month(), year(). This way, you are in control,
rather than the Regional Settings.

Bob Barrows
 
B

Bullschmidt

To make a variable be in the format of mm/dd/yyyy, 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 Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 

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
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top