If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > change date format

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-01-06, 16:41
freshfitz freshfitz is offline
Registered User
 
Join Date: May 2006
Posts: 20
change date format

I am tring to build a page to process credit cards. I am pulling info out of a sql database and I need to change the date from 1/1/2006 to 106 or 10/10/2006 to 1006 how would i do this this is the line i am calling to get the exp. date looks like this

<input type="text" value=<%=rcset.fields(83)%> name="amount" size="35">
Reply With Quote
  #2 (permalink)  
Old 06-01-06, 18:44
wayneph wayneph is offline
Registered User
 
Join Date: Aug 2005
Location: D/FW, Texas, USA
Posts: 78
Since it looks like you just want the month and year this should do it...

<%= Month(rcset.fields(83)) & Right(CStr(Year(rcset.fields(83))), 2) %>

Personally, I'd probably change the SQL Query so that the Format happens on the database side. But the option is up to you.
__________________
--wayne
SELECT * FROM Users WHERE Clue>0
0 rows returned
Reply With Quote
  #3 (permalink)  
Old 06-01-06, 21:11
freshfitz freshfitz is offline
Registered User
 
Join Date: May 2006
Posts: 20
That worked the only problem is if there is no credit card number it gives me an error not the end of the world, and if it is a single digit month it ends up being 106 i need 0106 but i can manualy enter that in if i have too

Last edited by freshfitz; 06-01-06 at 21:34.
Reply With Quote
  #4 (permalink)  
Old 06-02-06, 11:25
wayneph wayneph is offline
Registered User
 
Join Date: Aug 2005
Location: D/FW, Texas, USA
Posts: 78
Yes, there will be an error if there's no date there. You can put an If statement around it and only run it if there's a value.

You can get the leading zero automatically:

Right("0" & Month(rcset.fields(83)), 2) & ...
__________________
--wayne
SELECT * FROM Users WHERE Clue>0
0 rows returned
Reply With Quote
  #5 (permalink)  
Old 06-02-06, 12:34
freshfitz freshfitz is offline
Registered User
 
Join Date: May 2006
Posts: 20
Awesome thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On