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 March 10th, 2005, 06:04 AM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datet format result difference

Dear all,

I have written a ASP page to insert a date value "02/03/2005" (March 2 2005) from my ASP page via ODBC connection into Access file. When I open my Access, I saw that the value was changed to "03/02/2005".

Thus I copy my SQL query from ASP page, paste to Access program and run it. The value was "02/03/2005"

I don't know why it is difference result.

Please help.

Patrick Lee

 
Old March 10th, 2005, 10:43 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

While inserting data, use mm/dd/yyyy format..

Please check the following postings which might be useful:

http://p2p.wrox.com/topic.asp?TOPIC_ID=1431
http://www.15seconds.com/faq/Data%20Access/768.htm
http://www.developersdex.com/asp/mes...=576&r=3867407

Om Prakash
 
Old March 10th, 2005, 06:38 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
Default

There are lots of posts in this forum covering this topic in great detail. The actual international standard I believe is yyyy/mm/dd

Anyhow - I am in Aussie, we use the dd/mm/yyyy format here when showing dates on a page and asking a user for a date.

When using SQL Server or Access I always insert using a function to enforce the mm/dd/yyyy format, then when showing dates on a page I run another function to force the dd/mm/yyyy format

Here are the functions. These will resolve any date problems you may be having either when inserting or displaying dates on a page.

When inserting (forces mm/dd/yyy):
amDate(YourDateValue)

  FUNCTION amDate(varDate)
    IF DatabaseType = iDT_SQLServer THEN
      IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
        amDate = "Null"
      ELSE
        amDate = "'" & Month(DateValue(varDate)) & "/" & Day(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & " " & TimeValue(varDate) & "'"
      END IF
    ELSE
      IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
        amDate = "Null"
      ELSE
        amDate = "'" & Day(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & " " & TimeValue(varDate) & "'"
      END IF
    END IF
  END FUNCTION

When you have pulled a date in a record set and want to force the dd/mm/yyy format (assumes you have a date value in the first element of the record set named rs):

auDate(rs(0))

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

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
Convert Rich Text Format to Ordinary Format in ASP Andraw Classic ASP Basics 1 August 31st, 2007 10:05 AM
GridView and SQL More than one result = one result DarkForce ASP.NET 2.0 Basics 0 July 20th, 2007 04:29 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM
Code showing current datet& time of server pareshk Wrox Book Feedback 1 June 6th, 2005 10:06 PM





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