Date/time field type of MS Access database lazarus / 16-Databases ---------------------------------------------------------------------- asdf · 2012-12-01 11:07 How can I write codes to check the date format for each user ? Someone set up ther time date in their Windows like 'dd/mm/yyyy' but the others may setup 'mm/dd/yyyy'. Code: [Select]if thedateformat is 'dd/mm/yyyy' then thedatestring:=copy(sql1.FieldByName('Date1').Text,1,2)+'/'+copy .... if thedateformat is 'mm/dd/yyyy' then thedatestring:=copy(sql1.FieldByName('Date1').Text,4,2)+'/'+copy .... // I just need to use only 'dd/mm/yyyy' ---------------------------------------------------------------------- BigChimp · 2012-12-01 12:06 A bit of a provocative question but: why would you do that? If you use date controls instead of simple edits you won't have issues with formatting. If you output dates in reports etc you can: 1. Have an option in your program to select date format, e.g. -- ISO8.. whatever, basically the unambiguous YYYYMMDD HHNNSS or -- the local date format 2. Don't build in an option but just output in the user's format (with e.g. Sysutils.datetimetostr) as long as it is meant for display purposes. If the output is meant for interoperability (e.g. reading/writing files for transfer): use the ISO format ---------------------------------------------------------------------- asdf · 2012-12-01 17:43 It's because I have a stringgrid showing the existing data. ... 13/01/2012      for some users it shows 01/13/2012 14/01/2012 ... I want to read data from text files and insert into MS Access, the filename is like this: ... FS20120113.txt // date = 13, month = 01 & year = 2012 FS20120114.txt ... I just want to check and will not insert repeated data into the database. ---------------------------------------------------------------------- BigChimp · 2012-12-01 20:45 Well, I'd look up if there is a reverse function[1] to Sysutils.datetimetostr: a function that takes a string in the user's locale and converts it to a TDateTime and then forget about it... [1] Yes, there probably is such a function .... but I don't know it by heart. Also, looking up the function in the help will hopefully show pitfalls regarding too lax or too strict date recognition. ---------------------------------------------------------------------- Lacak2 · 2012-12-03 06:18 Quote from: asdf on December 01, 2012, 12:07:36 pmHow can I write codes to check the date format for each user ? Someone set up ther time date in their Windows like 'dd/mm/yyyy' but the others may setup 'mm/dd/yyyy'. Try FormatSettings.ShortDateFormat ---------------------------------------------------------------------- asdf · 2012-12-04 02:05 Quote from: Lacak2 on December 03, 2012, 07:18:00 amTry Code: [Select]FormatSettings.ShortDateFormat Thank you so much, that's what I've been waiting for  .