ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 23rd, 2009, 04:19 PM
edwardsfamily edwardsfamily is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 2 edwardsfamily User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 31 sec
Reputation Power: 0
ASP Date Help Needed

I will try to explain this problem the best I can. I use a credit card processor that requires a date to be submitted when sending the customer to the payment form. I have some code that was given to me to get the date and then put it in the form, so the customer doesn't have to. The processor requires the date but not the hour. The issue I have is the time difference between my host and the payment processor's server. There is a 3 hour difference, so this causes an error from 12 am to 3 am, in those 3 hours, the processor's server thinks it is the next day already and my host sends the date as the previous day. I will paste all of the code that I have and would really appreciate any help I can get. I need to add 3 hours to the date that is sent, but I only need it to send it in the format in the code of just the year, month and day.

This is the code below that works, but fails during the 12 am to 3 am hours. Any help that can be offered would be greatly appreciated. Thanks.

Code:
<%
Function FormatMediumDate(DateValue)
Dim strYYYY
Dim strMM
Dim strDD
strYYYY = CStr(DatePart("yyyy", DateValue))
strMM = CStr(DatePart("m", DateValue))
If Len(strMM) = 1 Then strMM = "0" & strMM
strDD = CStr(DatePart("d", DateValue))
If Len(strDD) = 1 Then strDD = "0" & strDD
FormatMediumDate = strYYYY & strMM & strDD
End Function
%>

Monthly charge of $1.00<br>
<form action="https://www.ccprocessor.com" method="post">
<input type="hidden" name="mode" value="fullpay">
<input type="hidden" name="txntype" value="sale">
<input type="hidden" name="submode" value="periodic">
<input type="hidden" name="periodicity" value="m1">
<input type="hidden" name="installments" value="-1">
<input type="hidden" name="threshold" value="2">
<input type="hidden" name="storename" value="123456">
<input type="hidden" name="chargetotal" value="1.00">
<input type="hidden" name="startdate" value="<% = FormatMediumDate(Date()) %>">
<input type="submit" value="Continue to secure Payment form" >
</form>

Reply With Quote
  #2  
Old July 23rd, 2009, 05:23 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
ASP Free God 17th Plane (13000 - 13499 posts)
 
Join Date: Feb 2005
Location: Dreamland
Posts: 13,237 mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)mehere User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 5 Months 1 Day 20 h
Reputation Power: 2012
-->Thread moved to ASP Development

you can do this by adding 3 hours to the datevalue before splitting M/D/Y ...
Code:
Function FormatMediumDate(DateValue)
	Dim strYYYY
	Dim strMM
	Dim strDD
	Dim strDate
	
	strDate = DateAdd("h",3,DateValue)
	
	strYYYY = CStr(DatePart("yyyy", strDate))
	strMM = CStr(DatePart("m", strDate))
	If Len(strMM) = 1 Then strMM = "0" & strMM
	
	strDD = CStr(DatePart("d", strDate))
	If Len(strDD) = 1 Then strDD = "0" & strDD
	
	FormatMediumDate = strYYYY & strMM & strDD
End Function
__________________
Come JOIN the party!!!

Quote of the Month:
Pretension: The downside of being better than everyone else is that people tend to assume you're pretentious.

Questions to Ponder:
You can be overwhelmed and underwhelmed, but why can't you be simply whelmed?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright© 2008 sbenj69

Reply With Quote
  #3  
Old July 23rd, 2009, 05:28 PM
edwardsfamily edwardsfamily is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 2 edwardsfamily User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 31 sec
Reputation Power: 0
Thanks. Someone also replied to me on another forum saying that using this would be more efficient.

Code:
<%
Function DateAtCCProcessor( )
    Dim today 
    today = DATEADD( "h", 3, Now() ) ' add 3 hours to get to CC processor time
    DateAtCCProcessor = Year(today) * 10000 + Month(today) * 100 + Day(today)
End Function
%>


and then this in the form

Code:
<input type="hidden" name="startdate" value="<%=DateAtCCProcessor( )%>">



If this method doesn't work I will use yours. Thank you so much for your help. Aslo, if anyone sees any reason why the new code I got from the other forum might cause a problem, please let me know.

Reply With Quote
  #4  
Old July 24th, 2009, 08:55 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,461 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Day 16 h 50 m 26 sec
Reputation Power: 1806
I cant see any reason why the code from the other forum wouldn't work and I agree that it is more efficient.

I've never seen that technique for formatting the date before but it is doing exactly the same as your original code.

For anyone who is wondering how it works: the original function breaks the date down into its component parts, padding the day and month values out to two digits and concatenating them back together in a different order:
Code:
Function FormatMediumDate(DateValue)
	Dim strYYYY
	Dim strMM
	Dim strDD
	Dim strDate

	strDate = DateAdd("h",3,DateValue)

	strYYYY = CStr(DatePart("yyyy", strDate))
	strMM = CStr(DatePart("m", strDate))
	If Len(strMM) = 1 Then strMM = "0" & strMM

	strDD = CStr(DatePart("d", strDate))
	If Len(strDD) = 1 Then strDD = "0" & strDD

	FormatMediumDate = strYYYY & strMM & strDD
End Function

The new function does exactly the same job but doesnt need to worry about padding the day/month values out to two digits because it is multiplying the value by a set number meaning that the day/month/year will always be in the correct position:
Code:
Function DateAtCCProcessor( )
    Dim today
    today = DATEADD( "h", 3,Now() ) ' add 3 hours to get to CC processor time
    DateAtCCProcessor = Year(today) * 10000 + Month(today) * 100 + Day(today)
End Function

For the date 31/12/2009 the function would convert it to:
(2009 * 10000) + (12 * 100) + 31 =
20090000 + 1200 + 31 =
20091231

Very clever!!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > ASP Date Help Needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek