US / UK date format - working demo

Results 1 to 3 of 3

Thread: US / UK date format - working demo

  1. #1
    DaveL Guest

    Default US / UK date format - working demo

    If you want to know how to convert dates to dd/mm/yyyy, please visit my working demo and grab the code at:<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default But does it work with variable dates???????

    Have a look at my code...<BR><BR>&#060;%<BR>Sub ShowUKdate()<BR><BR>dim dateStr, UKdate<BR>dateStr=split(RS("OfferingCreatedDate"), "/")<BR><BR>&#039add leading zero to single figures<BR><BR>if Len(dateStr(0))&#060;2 then<BR>dateStr(0)="0"&dateStr(0)<BR>end if<BR><BR>if Len(dateStr(1))&#060;2 then<BR>dateStr(1)="0"&dateStr(1)<BR>end if<BR><BR>if Int(dateStr(0))=month(now) then<BR>UKdate=dateStr(1)&"/"&dateStr(0)&"/"&dateStr(2)<BR>else<BR>UKdate=join(dateStr,"/")<BR>end if<BR><BR>response.write UKdate<BR>End Sub<BR>%&#062;<BR><BR>My variable date is &#060;%Response.Write RS("OfferingCreatedDate"%&#062;<BR><BR><BR>The date in the UK is &#060;% ShowUKdate %&#062;<BR><BR>This code produced the following.......<BR><BR>My variable date is 5/7/99<BR>The date in the UK is 07/05/99<BR><BR>Does this code work with variables? I also tried doing the following<BR><BR>dateStr=split("12/31/00","/")<BR><BR>This returned<BR><BR>The date in the UK is 12/31/00<BR><BR>How do you get 31/12/00?<BR><BR>Thanks <BR>Mike<BR><BR><BR>

  3. #3
    DaveL Guest

    Default RE: But does it work with variable dates???????

    As it stands, no, and it wasn&#039t designed for that. Remember that it compares each element of the dateStr array with the CURRENT date, so if you enter a date such as "12/31/00", neither the "12" nor the "31" is current, so it will just rejoin the original string.<BR><BR>The code was posted as a pointer towards ways of manipulating dates. I hope you find the idea helpful as a spring board for your own experiments.<BR><BR>Dave

Posting Permissions

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