Print Page | Close Window

date format

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14817
Printed Date: 30 March 2026 at 6:55am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: date format
Posted By: riya_singtel
Subject: date format
Date Posted: 25 April 2005 at 1:40am
I am using a date() function in asp using vb script. It returns the date in the format MM/dd/yyyy. Whereas I need it in dd/MM/yyyy.
 
I changed the date format of my computer to dd/MM/yyyy by going to Control panel ->Regional and Language Options.
 
It still displays the date in MM/dd/yyyy.
What can  be the reason?
Thanks



Replies:
Posted By: ub3rl337ch3ch
Date Posted: 25 April 2005 at 8:38pm
the date function inherently returns the computer dat in mm/dd/yyyy format, i believe. You need to find a script to format the date, like the Int() or FormatNumber() functions. I don't have one off hand though.


Posted By: riya_singtel
Date Posted: 26 April 2005 at 12:14am
Got this from http://www.codetoad.com/asp/format_date_time.asp - http://www.codetoad.com/asp/format_date_time.asp
 
 
You can use the session.lcid property to change the formatting of the date and time.

For example
<%session.lcid=2057%>
will set the date and time to UK format (DD/MM/YYYY instead of MM/DD/YYYY ) Here's a list of international locales. Bear in mind that setting these will also change currency formatting.
.....had been to this page before but somehow never noticed it then.
Thanks a lot


Posted By: riya_singtel
Date Posted: 26 April 2005 at 2:05am
I am using
<%session.lcid=2057%>
as mentioned in the above post. It displays the date in dd/mm/yyyy format 
But it gives one problem..whenever the date value is less than 13 it automatically converts it to mm/dd/yyyy format.
eg. i have a textbox where i have to enter the date.if i enter 01/03/2005 i.e 1st march in the database it stores it as 03/01/2005 i.e 3rd Jan
what can be the reason for this?
 


Posted By: C.P.A.
Date Posted: 26 April 2005 at 10:23am
use Session.LCID = 1043 instead


-------------
C.P.A. » The more you find out about the world, the more opportunities warmly welcome you.


Posted By: riya_singtel
Date Posted: 26 April 2005 at 9:05pm
1043 is for dutch format and it still does not work while i am making a query to the database


Posted By: Phat
Date Posted: 26 April 2005 at 11:17pm
try


<%

'================Format a date to the correct format=======================

Function AUSDate (str)

'Declaring the variables
Dim aDay
Dim aMonth
Dim aYear


If Len(Trim(str)) > 1 Then

    aDay = Day(str)
    aMonth = Monthname(Month(str),True)
    aYear = Year(str)
    AUSDate = aDay & "-" & aMonth & "-" & aYear

Else

    AUSDate = ""
   
End IF

End Function


%>



Posted By: C.P.A.
Date Posted: 27 April 2005 at 7:23am
Originally posted by riya_singtel riya_singtel wrote:

1043 is for dutch format and it still does not work while i am making a query to the database


Sorry you are right, but it should work for the database queries as well, make sure you use it through the entire process. (At least with me it has always worked just fine)


-------------
C.P.A. » The more you find out about the world, the more opportunities warmly welcome you.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net