Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 6th, 2007, 08:29 AM
Registered User
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default date field problem in access asp

anyone can pls help me, i am having problem with date field in access.
 I have used "dd/mm/yyyy" format in DB, but when data is stored through asp page,eg. 2/6/2007 i.e 2nd june 07,it is displayed as 6/2/2007 and when i click on it temporarily it displays 2/6/2007 but while retrieving in the query i have given order by desc, it considers it as 6/2/2007,anyone can help me pls..!!

Old June 6th, 2007, 07:02 PM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41

Dates are rendered on your asp page in the format of the servers local settings. IME it does not matter what this format is. You should always wrap functions around all dates rendered on a page. Even if your server is set to dd/mm/yyyy still wrap functions around them. This way your pages are more portable. You may think your pages will not be placed on another server, but, why take the risk!!!

Anyhow here are some functions I use day in day out:

This one will always give you dd/mm/yyyy (au is short for Australian):

  FUNCTION auDate(varDate)
    IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
      auDate = "Null"
      auDate = "" & Day(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & ""
    END IF

Another useful one I use all the time (Example output 13 Feb 2006). EG:

function customDate(varDate)
     if isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
        customDate = "Null"
        'customDate = "155 Jun 2006"
        customDate = Day(DateValue(varDate)) & " " & MonthName(DatePart("m", varDate), True) & " " & year(varDate)
         'customDate = Day(varDate) & " " & MonthName(DatePart("m", varDate), True) & " " & year(varDate)
     end if
  end function

You can see from these functions a date can be presented in any fashion regardless of the servers, or local settings. Place these in a global functions file, every time you render a date, use them.

Wind is your friend

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ORDER BY in SQL on date field in ASP page saifi4u Classic ASP Professional 3 March 1st, 2008 07:40 PM
date field problem access asp varia_mahesh Access ASP 0 June 6th, 2007 08:33 AM
ASP/Access Date Format seananderson Classic ASP Databases 2 November 6th, 2006 02:15 PM
sorting problem with a date field in gridview jwrz200t Visual Studio 2005 0 September 21st, 2006 01:19 PM
Accessing AutoNumber field of MS Access Using ASP MuthuAL Classic ASP Databases 1 January 22nd, 2005 11:30 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.