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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Date Formate 1

Status
Not open for further replies.

JaneB19

Technical User
Joined
Jun 27, 2002
Messages
110
Location
GB
Hi,

I was wondering if anybody knew/knows how to set the format of the date shown in a field on an ASP? I would like the date to be shown as "dd/mm/yyyy".

At the moment even if the date is entered in this format in the form, and the report pages the date is shown in "mm/dd/yyyy" fomat. I have the format set in the database as the format I would like it shown as, but that doesn't make any difference

Thanks

:-)

[PC2]
 
Morning Genimuse,

I've already got a line of coding pulling the data, you don't by any chance know how to have the FormateDateTime() around a field already taken from the database?

The following code is my attempt but it just generates an error!

<% = FormatDateTime(<% = objEmployeesRS.Fields(&quot;IncidentDate&quot;)%>, dd/mm/yyyy)

Somebody posted a thread about nesting <% %>s last week, but I can't find it to get the solution from! You didn't read it by any chance?

Thanks

:-)

[PC2]
 
you do not need to have anything around the value in the function. it will take strings and variable values the same
eg:
<%=FormatDateTime(objEmployeesRS.Fields(&quot;IncidentDate&quot;), dd/mm/yyyy)%>


also you should read
faq333-3194

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
whcih database are you using? SQL Server can return the data in the format you want: Something along the lines of:

CONVERT(VarChar(11), IncidentDate, 113) AS 'formattedDate'
 
Hi everyone,

I sussed what I'd done to get the error but it's still not working as I'd like it to. :-(

I'm using MS Access, for the database. I've set the field as short date in there, and it doesn't seem to matter that the date is entered and stored in the database as dd/mm/yyyy format, when pulling the date back out for the reports is still shows it as mm/dd/yyyy!

The FormatDateTime is displayed as mm/dd/yyyy and I've tried Date as well as CDate and any other date function that I can think of.

Do any of you know another date formatting function so that the date is shown as dd/mm/yyyy?

Thanks

[PC2]
 
you have the date from this
objEmployeesRS.Fields(&quot;IncidentDate&quot;)

so just take that value and tear it down and rebuild it with the day(date), month(date) and year(date) functions

The FAQ shows how to do this

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
At the top of your code add this line:

Code:
Session.LCID = 2057

That sets it to UK format and so when you use FormatDateTime it will output in dd/mm/yyyy format.

--James
 
Thank you all for your responses! And I very big thank you to JamesLean as you solved my problem. Not that I don't appreciate the time that everyone spent helping me out!

Have I dug myself back out of my grave yet? [wink]

Thanks again

Jane :-)

[PC2]
 
And credit to JamesLean for actually reading the original question -- I shouldn't answer these at 3 in the morning.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top