Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    202

    Unanswered: Change date format

    I got this one prob about date in ASP.

    If i want to display the date as from Wednesday, May 05, 2004 to
    2004-05-05, how do i actually do that?
    Thanx

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    I can't test this unfortunately but you might try.....

    myDate = "Wednesday, May 05, 2004 "
    myDay = day(myDate)
    myMonth = Month(myDate)
    myYear = year(myDate)
    myNewDate = myYear & "-" & myMonth & "-" & myDay

    You may have to change month and day to see if they need a 0 in front of them or not as well.

  3. #3
    Join Date
    Mar 2004
    Posts
    202
    Sorry but it come out nothing.My code is like this:

    mydate= ConvertDate(FormatDateTime(Date(), 1))
    myday=Day(mydate)
    mymonth=Month(mydate)
    myyear=Year(mydate)
    cutOffdate=myYear & "-" & myMonth & "-" & myDay
    ----------------------------------------------------------------
    the output for the "ConvertDate(FormatDateTime(Date(), 1))"
    is Wednesday, May 05, 2004.
    Please help me
    thanx

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Are you actually using.... mydate= ConvertDate(FormatDateTime(Date(), 1))??

    Because if you are.....

    mydate= Date()
    myday=Day(mydate)
    mymonth=Month(mydate)
    myyear=Year(mydate)
    cutOffdate=myYear & "-" & myMonth & "-" & myDay

    If you are stuck with this format Wednesday, May 05, 2004 then you might try this....
    myDate = "Wednesday, May 05, 2004"
    arrDate = split(myDate," ")
    myDate = CDate(left(arrDate(2),2) & "-" & arrDate(1) & "-" & arrDate(3))
    myday=Day(mydate)
    mymonth=Month(mydate)
    myyear=Year(mydate)
    cutOffdate=myYear & "-" & myMonth & "-" & myDay

  5. #5
    Join Date
    Mar 2004
    Posts
    202
    Thanx very much.
    I try and can already.
    Thanx again

Posting Permissions

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