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 February 26th, 2006, 08:43 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date formatting

Hi,

I'm using ASP and an Access Database for a project. I need to use a timestamp field, but if I mark the field Date/Time, I get an error message (Data mismatch). How can I use a text field with Now() but have it grab only the day date and not the time.

Example: 2/26/2006 instead of 2/26/2006 11:34:00am

Thanks for your help...you guys are awesome! :)
 
Old February 26th, 2006, 08:59 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

Why would you use a text field to hold a date. Use a date type data field and insert date() for just the date - dont forget to use the # around your dates in your statement

Wind is your friend
Matt
 
Old February 26th, 2006, 09:19 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I mark the field as a date, when pulling the field for an .asp page, I get a "data mismatch" error. Apparently this is a problem with Access/.asp per Microsoft. They suggested using a text field. Is there any way to create the timestamp using only the date portion, and not the time without using a date/time field type? OR I have a timestamp field, can I create a new field from it pulling only the date (2/26/2006) portion?

Thanks!
 
Old February 26th, 2006, 10:07 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

I use date/time but insert only the date. I am not aware of such a problem. What date format do you use? I use and insert dd/mm/yyyy

on insert run this function:

  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

INSRT INTO tbleName (dateField)VALUES('#" & auDate(myDatevar) & "
#');"



Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Formatting MargateFan XSLT 3 August 30th, 2006 07:42 AM
Date Formatting, need some assistance groovedrm Access VBA 2 June 16th, 2006 07:23 AM
Date Formatting ozPATT Excel VBA 2 October 31st, 2005 12:03 PM
formatting date time Adam H-W Classic ASP Basics 4 September 29th, 2004 03:35 AM
Formatting to a Date trekmp ADO.NET 2 March 16th, 2004 01:37 PM





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