Changing date format to YYYYMMDD

Results 1 to 3 of 3

Thread: Changing date format to YYYYMMDD

  1. #1
    J Guest

    Default Changing date format to YYYYMMDD

    Does anyone know how to change the date format of a variable? I know that I could write code to select the last 4 #'s and move them and so forth, but i figure there's got to be an easier way. Thanks

  2. #2
    Join Date
    Dec 1969

    Default FAQ

  3. #3
    J. Paul Schmidt Guest

    Default Or perhaps try this

    To make a variable be in the format of yyyymmdd, perhaps try something like the following which you might even make into a function:<BR><BR>varFld = CDate(MyVariable)<BR><BR>intMonth = Month(varFld)<BR>intDay = Day(varFld)<BR>intYr = Year(varFld)<BR><BR>If intMonth &#060; 10 Then<BR> strMonth = "0" & CStr(intMonth)<BR>Else<BR> strMonth = CStr(intMonth)<BR>End If<BR><BR>If intDay &#060; 10 Then<BR> strDay = "0" & CStr(intDay)<BR>Else<BR> strDay = CStr(intDay)<BR>End If<BR><BR>varFld = CStr(intYr & strMonth & strDay)<BR><BR>Best regards,<BR>-Paul<BR><BR>J. Paul Schmidt, MBA<BR>Databases on the Web<BR><BR><BR><BR>

Posting Permissions

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