Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old May 22nd, 2012, 01:06 PM
Authorized User
Points: 147, Level: 2
Points: 147, Level: 2 Points: 147, Level: 2 Points: 147, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 34
Thanks: 1
Thanked 1 Time in 1 Post
Default Need help putting in right Date format for Now().

I have a page that we will be updating a field. I have a hidden field that carries over to an update page. I only want the Date without the time.

Code:
Code:
cpReviewDate = Now()	

 <INPUT TYPE="Hidden" NAME="cpDate" VALUE="<%= cpReviewDate %>">
This then gets processed in my update page:

Code:
objRS("cp_ReviewDate") = Request.Form("cpDate")
objRS("buildTech") = Request.Form("buildTech")
objRS.Update
End result right now shows: 5/21/2012 5:04:32 PM

I would only like to show the date and not the time: 5/21/2012.

Please let me know if any more information is needed.

Thanks
  #2 (permalink)  
Old May 22nd, 2012, 01:11 PM
Authorized User
Points: 147, Level: 2
Points: 147, Level: 2 Points: 147, Level: 2 Points: 147, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 34
Thanks: 1
Thanked 1 Time in 1 Post
Default

Well, that did not take long. I found in one of my old books, change Now() to Date(). Created the correct format.

Thanks
  #3 (permalink)  
Old May 22nd, 2012, 07:49 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

HI there - nice of you to blow the dust of this forum category, it doesn't get much action these days...

When dealing with dates and date formats you can either gamble and roll the dice as you are doing by using date() and now() or write functions to ensure not only the part of the date/time are there but they are in the format you want EG dd/mm/yyyy is essential for Australia. SO:

when I insert a record into SQL Server I like to always store using American mm/dd/yyyy format so I do use this function:

Code:
  FUNCTION amDate(varDate)
      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 
  END FUNCTION
and when I get records from the DB I display it using either of these functions, the first one shows just the date and the second one the date and time:

Code:
  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
  
  FUNCTION auDateTime(varDate)
      IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
        auDateTime = "Null"
      ELSE
        auDateTime = "" & Day(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & " " & TimeValue(varDate) & ""
      END IF 
  END FUNCTION
Then once you build your functions up you will use then everywhere....
__________________
Wind is your friend
Matt


Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Convert date to JDEdwards date format snufse ASP.NET 2.0 Basics 1 March 24th, 2009 08:54 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM
putting a date into a date field elladi Classic ASP Databases 2 March 31st, 2005 01:30 PM





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