Text to Date Conversion

Hi Can somebody show me how to convert text to date? I want to get “Date Filter” from Filters and then convert the text eg. 31/12/04 to 31st January 2004. The other issue is that I want to format date textbox so that user can only give one date and not the range of date. I am not using request form but it opens the normal Item table field list menus. Thanks in advance.

to convert common datatypes to Text you should use the FORMAT command. For very good description check out the help file. (You should read the help on the FORMAT command AND the FORMAT property). WRT restricting the date to a single date are you talking about on a report? You could put some code in the OnPreReport trigger to test the filtervalue and then show an error. (Using GETRANGEMIN and GETRANGEMAX) Hope this helps you out a little.

use the EVALUATE function for converting text into date. This works as long as you are doing it in the same Navision session without any problems. It could lead into problems when you are either reading dates from a field which has been filled by another machine or from another external program (like text file import) because of different date formats.

To convert the text eg. 31/12/04 to 31st January 2004, I used a small function to return the text format. (Is there any standard functionality to get the output ?) FunGetFullTextDate(31/12/04); will return 31,January 2004 Function code : //murugan vDay := DATE2DMY(mDate,1); vMonth := DATE2DMY(mDate,2); vYear := DATE2DMY(mDate,3); IF vMonth = 1 THEN vMonthText := ‘January’; IF vMonth = 2 THEN vMonthText := ‘February’; IF vMonth = 3 THEN vMonthText := ‘March’; IF vMonth = 4 THEN vMonthText := ‘April’; IF vMonth = 5 THEN vMonthText := ‘May’; IF vMonth = 6 THEN vMonthText := ‘June’; IF vMonth = 7 THEN vMonthText := ‘July’; IF vMonth = 8 THEN vMonthText := ‘August’; IF vMonth = 9 THEN vMonthText := ‘September’; IF vMonth = 10 THEN vMonthText := ‘October’; IF vMonth = 11 THEN vMonthText := ‘November’; IF vMonth = 12 THEN vMonthText := ‘December’; vFullText := FORMAT(vDay)+’, '+ vMonthText + ', '+ FORMAT(vYear); EXIT(vFullText); //murugan

quote:

To convert the text eg. 31/12/04 to 31st January 2004, I used a small function to return the text format. (Is there any standard functionality to get the output ?)
Originally posted by murugan - 2005 Feb 16 : 09:39:20

Yes there is: FunGetFullTextDate(TextDate) as Text EVALUATE(DateVar,TextDate); EXIT(Format(DateVar,0,'<Day>,<Month Text> <Year4>));

Thanks Thomas.

always welcome