How to convert a string value to an appropriate date and time format

Using Crystal Report 7

I want to convert string value to datetime in crystal report

date format

20120102 (yyyymmdd) 20120105 ... 

I want to convert the above string format to date format

expected output

 02/01/2012 05/01/2012 ... 

Need help with Crystal Report Formula

+4
source share
4 answers

You can try the DateValue function:

 DateValue({myTable.strDate}) 

otherwise analyze it:

 Date({myTable.strDate}[1 to 4], {myTable.strDate}[5 to 6], {myTable.strDate}[7 to 8]) 
+7
source

Try customizing the formula, for example:

 Date (ToNumber (Right ({myTable.strDate}, 4)), ToNumber (Mid ({myTable.strDate}, 5, 2)), ToNumber (Left ({myTable.strDate}, 2)) ) 
+1
source

The above answer does not work for a typical date, which is currently in yyyymmdd string format. The "left" and "right" should be replaced.

 (date (ToNumber (Left ({?LD}, 4)), ToNumber (Mid ({?LD}, 5, 2)), ToNumber (Right ({?LD}, 2)) ) 
+1
source
 cDate(ToText(cDate({?StartDate}),"yyyyMMdd"))) 
+1
source

Source: https://habr.com/ru/post/1399539/


All Articles