sDateConverted=Format(Date,"YYYY/MM/DD") 'Type

Results 1 to 2 of 2

Thread: sDateConverted=Format(Date,"YYYY/MM/DD") 'Type

  1. #1
    Stellus Guest

    Default sDateConverted=Format(Date,"YYYY/MM/DD") 'Type

    I tried all the combination, just to convert the date!!<BR>It keeps giving eroors<BR><BR>Here is my code...<BR>Dim sDateConverted<BR><BR>sDateConverted=Format(Date," YYYY/MM/DD") &#039Type mismatch error<BR>sDateConverted=cstr(Format(Date,"YYYY/MM/DD")) &#039Type mismatch error<BR>Can anyone help?<BR>thanks<BR>Stellus

  2. #2
    Join Date
    Dec 1969

    Default RE: sDateConverted=Format(Date,

    I&#039m not aware of a single formatting function in VBScript that will do what you want but you may want to try this:<BR><BR>If the variable theDate holds the current date (i.e. theDate = Date) then you can extract the parts you want like this:<BR><BR>theYear = DatePart("yyyy", theDate)<BR>theMonth = DatePart("m", theDate)<BR>theDay = DatePart("d", theDate)<BR><BR>Then, concatenate them together:<BR><BR>theWholeDate = theYear & "/" & theMonth & "/" & theDay<BR><BR>If the month or day you convert have only one digit the DatePart function will only return one digit. If you want to precede single digit months or days with a zero you&#039ll have to maually code that.<BR><BR><BR>Happy programming --<BR><BR>Joel

Posting Permissions

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