change month value to text

Discussion in 'AutoCAD' started by nalsur8, Aug 6, 2004.

  1. nalsur8

    nalsur8 Guest

    (setq date (getvar "CDATE")
    datee (rtos date 2 4)
    year (substr datee 1 4)
    month (substr datee 5 2)
    day (substr datee 7 2)
    )
    how to change month value "08" to text "Aug"
    ("01"-> Jan , "02" ->Feb and so on...)
     
    nalsur8, Aug 6, 2004
    #1
  2. nalsur8

    Jürg Menzi Guest

    Hi nalsur8

    Try this function:
    ;
    ; -- Function ConvJulianDate
    ; Convert julian date/time (also serial) to standard format.
    ; Arguments [Typ]:
    ; Val = Julian date/time [REAL]
    ; Mde = Conversion mode, eg. "MO/DD/YYYY H:MMam/pm" [STR] *)
    ; Return [Typ]:
    ; > Formatted date/time [STR]
    ; Notes:
    ; *) Details for mode see Diesel, edtime
    ;
    (defun ConvJulianDate (Val Mde / TmpVal)
    (setq TmpVal (if (minusp (- Val 2415019.0)) (+ Val 2415019.0) Val))
    (menucmd (strcat "M=$(edtime," (rtos TmpVal) "," Mde ")"))
    )
    Usage:
    (ConvJulianDate (getvar "DATE") "DD. MON YYYY")
    Note: (getvar "DATE") required

    Cheers
     
    Jürg Menzi, Aug 6, 2004
    #2
  3. or
    (setq date (getvar "CDATE")
    datee (rtos date 2 4)
    year (substr datee 1 4)
    month (substr datee 5 2)
    day (substr datee 7 2)
    )
    (cond
    ((= (atof month) 1) (setq monthtext "Jan"))
    ((= (atof month) 2) (setq monthtext "Feb"))
    ((= (atof month) 3) (setq monthtext "Mar"))
    ((= (atof month) 4) (setq monthtext "Apr"))
    ((= (atof month) 5) (setq monthtext "May"))
    ((= (atof month) 6) (setq monthtext "Jun"))
    ((= (atof month) 7) (setq monthtext "Jul"))
    ((= (atof month) 8) (setq monthtext "Aug"))
    ((= (atof month) 9) (setq monthtext "Sep"))
    ((= (atof month) 10) (setq monthtext "Oct"))
    ((= (atof month) 11) (setq monthtext "Nov"))
    ((= (atof month) 12) (setq monthtext "Dec"))
    )
    (setq datetext (strcat monthtext " " (itoa (atoi day) ", " year))
     
    Alan Henderson @ A'cad Solutions, Aug 6, 2004
    #3
  4. nalsur8

    PG. Guest

    or
    (setq date (getvar "CDATE")
    datee (rtos date 2 4)
    year (substr datee 1 4)
    month (substr datee 5 2)
    day (substr datee 7 2)
    )
    (setq months '("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct"
    "Nov" "Dec"))
    (setq monthtext (nth (1- (atoi month)) months))

    (setq datetext (strcat monthtext " " day ", " year))
     
    PG., Aug 6, 2004
    #4
  5. nalsur8

    Guest Guest

    thanks you guys....
     
    Guest, Aug 7, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.