my smallDate values are dropping their leading zer

Results 1 to 5 of 5

Thread: my smallDate values are dropping their leading zer

  1. #1
    ASP Doofus Guest

    Default my smallDate values are dropping their leading zer

    My app retreives a value for &#039;Last Business Day&#039; from a database. The returned date has leading zeros (ie--06/05/2001 as opposed to 6/5/2001). I then output this value into an HTML textbox, but it appears in a browser without the leading zeros. The web server&#039;s regional setting for short date format is &#039;MM/dd/yyyy&#039; and I have tried a line of code like &#039;yesterday = FormatDateTime(yesterday,2)&#039;, but my app still wants to drop the zeros. <BR><BR>Any help anyone could provide would be GREATLY appreciated.

  2. #2
    KevinT Guest

    Default A really lousy way to do it

    I battled with with for a while and eventually gave up and now just keep all of my dates as strings. A gimp way to do it, but it works for now.

  3. #3
    ASP Doofus Guest

    Default Thanks. I have a follow-up question.

    Thanks for the advice, but I have a follow-up question...<BR><BR>How do I specify that the value should be a String? Can you cast in ASP?

  4. #4
    Join Date
    Dec 1969

    Default I use this sometimes... strip the date out of a datetime field with hours and minutes in it as well. I couldn&#039;t always get the desired result so this function really helps me out. <BR><BR><BR>function ConvertDate(sDate)<BR> dim sYYYYStart<BR> dim sMM<BR> dim sDD<BR> dim sYYYY<BR> dim sDay<BR> <BR> sDate = Trim(sDate)<BR> <BR> if sDate = "" then exit function<BR><BR> if mid(sDate,2,1) = "/" then sDate = "0" & sDate<BR> if trim(mid(sDate,6,1)) &#060;&#062; "/" then<BR> sDay = trim(mid(sDate,4,1))<BR> sDD = "0" & sDay<BR> else<BR> sDD =mid(sDate,4,2)<BR> end if<BR><BR> sMM = trim(mid(sDate,1,2))<BR> sYYYYStart = InstrRev(sDate,"/",Len(sDate),vbTextCompare)<BR> sYYYY = Trim(Mid(sDate,sYYYYStart + 1,4))<BR> if len(sYYYY)&#060;4 then sYYYY= "20" & sYYYY<BR> sDate = sMM & "/" & sDD & "/" & sYYYY<BR><BR> ConvertDate = trim(mid(sDate,1,10))<BR><BR> end function

  5. #5
    Join Date
    Dec 1969

    Default Not a good idea...

    ...This can cause problems down the road when you want to compare dates. Your DB won&#039;t handle them properly and you&#039;ll be forced to use inefficient methods to get around the problem.

Posting Permissions

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