How to convert DATE value to STRING

How do i assign DATE value to STRING character.

For example i have 2 different data type 1) Job_Date which is a Date Data type and 2) Job_Date_Char is STRING(10) Data type .
I need Job_Date = ‘28/01/2023’ to be re-assinged to Job_Date_Char so that Job_Date_Char must contain the character value of ‘28/01/2023’.

I had written code for these kind of conversion in other technology and I tried to implement the same logic here but didn’t work. The value of Job_Date_Char holds numeric value some thing like 783456.
Your suggestion would be much appreciated.

Thanks

KK

Look in the help for date pictures and formatting, the UK style date format dd/mm/yyyy is via @D06, there are examples both ways, ie: to and from both strings and values.

https://clarion.help/doku.php?id=standard_date.htm

https://clarion.help/doku.php?id=date_pictures.htm

1 Like

Hello, look at the DEFORMAT and FORMAT commands

1 Like

Hello, declare:
DATA
Job_Date date()
or
Job_Date long()
in the code you put
Job_Date_Char=deformat(Job_Date,@d6) !to 1/02/2023
Job_Date_Char=deformat(Job_Date,@d06) !to 01/02/2023
Doubts about the Picture of the dates look in the help:
DATE (return standard date)
And on the same page
DEFORMAT

2 Likes

Hi Jorge

I think you meant to use Format not DeFormat.

Job_Date_Char=format(Job_Date,@d6)  !to 1/02/2023
Job_Date_Char=format(Job_Date,@d06) !to 01/02/2023

cheers

Hello vitesse, welcome, yes you are right is that I made both forms and passed only one of them…

Date
Loc:dateCw…date() or long()
Loc:dateSql…string(10)

Code
1 - to send to Base SQL in string format (yyyy-mm-dd)
Loc:dateSql = FORMAT(Loc:dateCw,@d10-)

2 - to return a Long() with the Date value for format calculations (dd/mm/yyyy) from string
Loc:dateCw = DEFORMAT(Loc:dateSql,@d06)

thank you…!

1 Like