Results 1 to 5 of 5
  1. #1
    Join Date
    May 2006
    Posts
    20

    Unanswered: 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">

  2. #2
    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

  3. #3
    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 22:34.

  4. #4
    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

  5. #5
    Join Date
    May 2006
    Posts
    20
    Awesome thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •