Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ordinal Date

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
1267 Views, 9 Replies

Ordinal Date

Does anyone know if there is a way to format the date fields to display as an ordinal date? (ie. 21st of January, 2014)

9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

you looking for  something like this?

%<\AcVar CreateDate \f "d of MMMM, yyyy">%

 

Message 3 of 10
Anonymous
in reply to: Anonymous

Not quite. I need the ordinal version of the date where the day is listed
as 1st, 2nd, 3rd, 4th etc. Any ideas for that?

--

*Chantelle Opdahl*

Survey CAD Drafter





*MISSION*

GEOSPATIAL

[p] 403.668.4604 [f] 403.668.4622

[e] copdahl@mGeo.ca *www.mGeo.ca*
3320 8th Street S.E., Calgary, Alberta T2G 5S7
Message 4 of 10
Anonymous
in reply to: Anonymous

If you want to go the lisp way, I CAN help you with that. If not, this is all that I know for fields (as far as date stamps are concerned)... Let me know

Message 5 of 10
AcadAdamLT
in reply to: Anonymous

None of the standard field date variables that suites you?

use the "Field" command and see the different formats for yourself.

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 6 of 10
hwalker
in reply to: Anonymous

That's when I turned 44.

 

Unfortunately there is no OOTB answer

 

You would have to write a lisp routine which would

 

1. Get the date

2. Check the last digit

3. Add the following text depending on the digit

1 = st

2 = nd

3 = rd

4 to 0 = th

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 7 of 10
Anonymous
in reply to: Anonymous

(defun c:test ( / *error* date mtext pt )
  (vl-load-com)
  (defun *error* ( m )
    (or (wcmatch (strcase m) "*BREAK,*CANCEL*,*EXIT*")
         (princ (strcat "\n** Error: " m " **")))
    (princ)
  )

  (defun date ( / fixday d )
    (defun fixday ( str / n )
      (strcat (itoa (atoi str))
        (cond 
          ( (and (< 3 (setq n (atoi str)))(> 21 n)) "th" )
          ( (eq "1" (setq n (substr str (strlen str))))
            "st"
          )
          ( (eq "2" n) "nd")
          ( (eq "3" n) "rd")
          ( "th")
        )
      )
    )
  
    (strcat 
      (fixday 
        (substr (setq d (menucmd "M=$(edtime, $(getvar,date),MoDDYYYY)"))
          3 2
        )
      ) " of "
      (nth (1- (atoi (substr d 1 2)) )
        '("January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December")
      ) ", " (substr d 5)
    )
  )

  (defun mtext ( content height layer just insertionpoint flag / e )
    (setq e
      (entmakex
        (list
          (cons 0   "MTEXT")
          (cons 100 "AcDbEntity")
          (cons 67  0)
          (cons 8   layer)
          (cons 100 "AcDbMText")
          (cons 10  insertionpoint)
          (cons 40  height)
          (cons 71  just) 
          (cons 72  5) 
          (cons 1   content)
          (cons 7   (getvar 'textstyle)) 
          (cons 11  (list 1.0 0.0 0.0))
          (cons 90 3)
          (cons 63 256)
          (cons 45 1.1)
  	  (cons 441 0)
        )
      )
    )
    (if (and e flag)
      (vlax-ename->vla-object e) e
    )
  )

  (if 
    (setq pt (getpoint "\nSpecify insertion point of Date: "))
    (progn
      (mtext (date) (getvar 'textsize)(getvar 'clayer) actopleft pt nil)
    )
  ) (princ)
)

 I couldn't resist! Smiley Happy

Message 8 of 10
AcadAdamLT
in reply to: Anonymous

Haha gotta love the entusiasm 🙂

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 9 of 10
Anonymous
in reply to: AcadAdamLT

I noticed you're an LT user... here ya go!

Message 10 of 10
Anonymous
in reply to: hwalker

Hi!

 

Is there any development in that would add the st, nd, th automatically? I still don't see a date type that offers that in the field creator tab, but I'm also not competent enough to do that lisp thing. 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost