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 October 15th, 2004, 04:01 PM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date format problem

Hi all,
     Thanks for all the questions you have answered.I have this code.I want the final dates as mm/dd/yyyy.but am getting only one digit for day and month.This is a very basic question,but i am learning.please help.Thanks.

<%@ Language=VBScript %>
<% Response.Buffer = True %>
<%
Dim freq
freq="222"
d=Now()
 d=FormatDateTime(d, 2)
 select case freq
 Case "0"
     begdate=d

 Case "1"
     end1=DateAdd("d", -1, d)
     begdate=Month(end1) & "/" & Day(end1) & "/" & Year(end1)
    'Response.write "Daily date of interest" & begdate
 case "222"
     k=Weekday(CDate(d))
    end1=DateAdd("d", -k, d)
    begdate=Month(end1) & "/" & Day(end1) & "/" & Year(end1)
    beg=DateAdd("d", -(k+6),d)
    enddate=Month(beg) & "/" & Day(beg) & "/" & Year(beg)
    'Response.write" Beg period is" & begdate
    'Response.write" Ending period is" & enddate
case "333"
    k=Weekday(CDate(d))
    end1=DateAdd("d", -k, d)
    begdate=Month(end1) & "/" & Day(end1) & "/" & Year(end1)
    beg=DateAdd("d", -(k+13),d)
    enddate=Month(beg) & "/" & Day(beg) & "/" & Year(beg)
    'Response.write" Beg period is" & begdate
    'Response.write" Ending period is" & enddate
case "444"
    EndDate = DateSerial(year(date()), month(date()), 0)
    BegDate = DateSerial(year(date()), month(date())-1, 1)
    'Response.write" Beg period is" & begdate
    'Response.write" Ending period is" & enddate
case "555"
    EndDate = DateSerial(year(date()), month(date()), 0)
    BegDate = DateSerial(year(date()), month(date())-3, 1)
    'Response.write" Beg period is" & begdate
    'Response.write" Ending period is" & enddate
case "666"
    EndDate = DateSerial(year(date()), month(date()), 0)
    BegDate = DateSerial(year(date()), month(date())-6, 1)
    'Response.write" Beg period is" & begdate
    'Response.write" Ending period is" & enddate
case "777"
    EndDate = DateSerial(year(date()), month(date()), 0)
    BegDate = DateSerial(year(date()), month(date())-12, 1)
    'Response.write" Beg period is" & begdate
    'Response.write" Ending period is" & enddate
End Select
Response.write "Beg date is" & BegDate & "<br>"
Response.write "End date is" & EndDate
%>

Widad

 
Old October 15th, 2004, 06:31 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

This function will give you mm/dd/yyyy date format no matter what your local settings are:
-------------------
  function mmddyyy(varDate)
     mmddyyy = Month(DateValue(varDate)) & "/" & Day(DateValue(varDate)) & "/" & Year(DateValue(varDate))
  end function

  response.write mmddyyy(date)
-----------------------------

I didnt run youer code, by the looks of things:
;;;Response.write "Beg date is" & BegDate & "<br>"
Response.write "End date is" & EndDate

Are you end dates, so:

Response.write "Beg date is" & mmddyyy(BegDate) & "<br>"
Response.write "End date is" & mmddyyy(EndDate)

Should do it. Note: Make sure you pass a valid date/not null value to the function or it will error (you should probably add this to the function)

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date format problem abhishekkashyap27 C# 2005 1 June 23rd, 2008 02:25 AM
Date Format Problem cyberddindia Classic ASP Basics 2 October 23rd, 2006 01:49 AM
Date Format Problem Scripts82 Access VBA 2 March 13th, 2006 09:36 PM
Date format problem ERC Crystal Reports 1 June 15th, 2005 04:03 AM
Date Format problem in Oracle ppenn Oracle ASP 1 May 10th, 2004 06:00 PM





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