PDA

View Full Version : How to get a date in a DD/MM/YY format?


eblanco_74
2006-07-17, 05:43 PM
How to get a date in a DD/MM/YY format? Is there any way to convert from the format DATE variable shows? Mathematics convertions from this format seems very tricky.

TIA
Eric

T.Willey
2006-07-17, 05:48 PM
You can use this. Called like (GetDate)

(defun GetDate (/ CurDate)
; Get the current date as string

(setq CurDate (rtos (getvar "CDATE") 2 4))
(setq CurDate (strcat (substr CurDate 5 2)"/"(substr CurDate 7 2)"/"(substr CurDate 3 2)))
)

rkmcswain
2006-07-17, 07:30 PM
How to get a date in a DD/MM/YY format? Is there any way to convert from the format DATE variable shows? Mathematics convertions from this format seems very tricky.

TIA
Eric

Here is one way:


(menucmd "M=$(edtime,$(getvar,date),DD/MO/YY)")



...returns 17/07/06

Adesu
2006-07-18, 02:38 AM
How to get a date in a DD/MM/YY format? Is there any way to convert from the format DATE variable shows? Mathematics convertions from this format seems very tricky.

TIA
Eric

Hi eblanco,
here code to display date-month-year as you looking for

(defun c:test (/ DATE DISPLAY HOUR MINUTE MONTH TIME YEAR)
(setq time (rtos (getvar "CDATE")))
(setq year (substr time 1 4))
(setq month (substr time 5 2))
(setq date(substr time 7 2))
(setq hour (substr time 10 2))
(setq minute (substr time 12 2))
(alert (strcat date "/" month "/" year
" " "<" hour " " minute "'" ">"))
(princ)
)

rkmcswain
2006-07-18, 04:49 AM
eblanco_74, if you want to use all that code, you'll have to make a few minor changes in order for this to return the desired output as you specified in your original post


(defun test (/ DATE DISPLAY HOUR MINUTE MONTH TIME YEAR)
(setq time (rtos (getvar "CDATE")))
(setq year (substr time 3 2))
(setq month (substr time 5 2))
(setq date(substr time 7 2))
(setq hour (substr time 10 2))
(setq minute (substr time 12 2))
(strcat date "/" month "/" year)
)


I'm still partial to the single line of code above though... :p

Adesu
2006-07-25, 08:30 AM
Hmm.......discount 5% or snip part of original code

eblanco_74, if you want to use all that code, you'll have to make a few minor changes in order for this to return the desired output as you specified in your original post


(defun test (/ DATE DISPLAY HOUR MINUTE MONTH TIME YEAR)
(setq time (rtos (getvar "CDATE")))
(setq year (substr time 3 2))
(setq month (substr time 5 2))
(setq date(substr time 7 2))
(setq hour (substr time 10 2))
(setq minute (substr time 12 2))
(strcat date "/" month "/" year)
)


I'm still partial to the single line of code above though... :p