Board index » delphi » Date Format & Local SQL

Date Format & Local SQL

Hi,
The BDE accepts and generates dates according to int'l settings, for example
"31-12-99". However Local SQL does not recognize these settings and only
accepts "M/D/Y" format despite other Windows- and BDE administrator
settings. Questions:
1. Can I instruct Local SQL to accept other date formats?
2. If not, does Local SQL always and only apply the "M/D/Y" format?

Who knows?

Jaap

 

Re:Date Format & Local SQL


On Thu, 19 Aug 1999 21:09:46 +0200, "Jaap Stegenga" <jhstege...@tip.nl>
wrote:

Quote
>The BDE accepts and generates dates according to int'l settings, for example
>"31-12-99". However Local SQL does not recognize these settings and only
>accepts "M/D/Y" format despite other Windows- and BDE administrator
>settings. Questions:
>1. Can I instruct Local SQL to accept other date formats?
>2. If not, does Local SQL always and only apply the "M/D/Y" format?

From the local SQL online help file, LOCALSQL.HLP, found in the main BDE
directory...

There are two acceptable formats for the date parts of DATE and TIMESTAMP
literals in local SQL statements: the US date format and the European date
format. Which one of the two you use is predicated on the Windows
configuration settings for Date Separator and Short Date Style. If the Date
Separator is a slash (/) and Short Date Style puts the month before the day
(such as MM-dd-yy), the date must be in a US date format, MM/DD/YY or
MM/DD/YYYY. If the Date Separator is a period (.) and Short Date Style puts
the day before the month (such as dd.MM.yy), the date must be in a European
date format, DD.MM.YY or DD.MM.YYYY. A combination of Short Date Style of
month before day and a Date Separator of anything but a period is not
supported in local SQL. DATE and TIMESTAMP values passed to an SQL
statement via parameters and the values in columns are unaffected by these
restrictions on format. Only literal values are affected.

To prevent date literals from being mistaken by the SQL parser for
arithmetic calculations, enclose them in quotation marks. This keeps
1/23/1998 from being mistaken for 1 divided by 23 divided by 1998.

Example of a date literal in a US format:

  SELECT *
  FROM orders
  WHERE (saledate <= "1/23/1998")

Example of the same date literal in a European format:

  SELECT *
  FROM orders
  WHERE (saledate <= "23.1.1998")

Leading zeros for the month and day fields are optional.

If the century is not specified for the year in a date value, the BDE
settings FOURDIGITYEAR and YEARBIASED control the century of the date.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski                               "You may already be a loser."
Felton, CA                                      -- Form letter received by
                                                   Rodney Dangerfield

Re:Date Format & Local SQL


Isn't it better to change system date while application is running to
avoid mistakes? I would like to do that, but I need help.

on form create:
Change date to German style //mm.dd.yyy

On form destroy:
Restore to original date system

Anyone can help?

TIA
Beli

Re:Date Format & Local SQL


I use one technique while starting application.
I normally have one routine start application and in that I put the
following command to control data string :

   { set up formatting here}
   ShortDateFormat := 'dd/mm/yyyy';
   CurrencyString := '';

You can easily store the current setting and restore on closeapplication.

Hope this helps.
---------------------------------------
Natwar Lath
1A Shree Complex
Uditnagar
ROURKELA 769012 (INDIA)

In article <7pj472$uh...@avala.yubc.net>, newsmas...@sauron.co.yu says...

Quote
> Isn't it better to change system date while application is running to
> avoid mistakes? I would like to do that, but I need help.

> on form create:
> Change date to German style //mm.dd.yyy

> On form destroy:
> Restore to original date system

> Anyone can help?

> TIA
> Beli

Other Threads