Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 15th, 2004, 04:01 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old October 15th, 2004, 06:31 PM
Friend of Wrox
Points: 6,462, Level: 34
Points: 6,462, Level: 34 Points: 6,462, Level: 34 Points: 6,462, Level: 34
Activity: 77%
Activity: 77% Activity: 77% Activity: 77%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,834
Thanks: 12
Thanked 16 Times in 16 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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08: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



All times are GMT -4. The time now is 08:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.