Recent

Author Topic: Database and date format variable  (Read 6291 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Database and date format variable
« on: June 23, 2011, 02:17:59 pm »
A curiosity, because the databases do not always use the same date format and the same character in order to perform a search in a date field in sql I was wondering if you had data that could be obtained. If you like? Thanks for the help.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Lacak2

  • Guest
Re: Database and date format variable
« Reply #1 on: June 27, 2011, 07:47:50 am »
Can you be here more concrete please.
Which databases ?
Are you speaking about writing cross database application, which must work with various databases, which use various datetime literal format ?
(sql standard specifies, that datetimes are in format : 'yyyy-mm-dd hh:nn:ss.sss' = year-month-day hour:minute:second with single quotes around)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Database and date format variable
« Reply #2 on: June 27, 2011, 07:57:56 am »
Exactly, I was curious to know the format, however, cross-databases from the point of view of queries such as MSSQLServer use # # to include the date, while other characters can use different DB I semmbra. Then MSSQLServer always uses / day as the divisor of the year and month, for example using Firebird -. So I'd like to know if there is a function that retrieves these parameters.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Database and date format variable
« Reply #3 on: June 27, 2011, 09:47:18 am »
As far as I remember, if you use date parameters in your sqldb queries, SQLDB will translate the dates to the proper format.
Yet another reason to use parameters if possible.
Lacak is right about the SQL standard; however, I think there are some databases that don't support microseconds, but SQLDB should deal with this.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Lacak2

  • Guest
Re: Database and date format variable
« Reply #4 on: June 27, 2011, 12:37:10 pm »
Exactly, I was curious to know the format, however, cross-databases from the point of view of queries such as MSSQLServer use # # to include the date,
MS SQL Server accepts various formats of datetime values, but also accepts SQL standard ('yyyy-mm-dd')
May be, that you are speaking about MS Access, which accepts #mm/dd/yyyy#

So I'd like to know if there is a function that retrieves these parameters.
No, AFAIK
As BigChimp wrote, you can use parameters in your SQL queries

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Database and date format variable
« Reply #5 on: June 27, 2011, 12:47:11 pm »
MS SQL Server accepts various formats of datetime values, but also accepts SQL standard ('yyyy-mm-dd')
May be, that you are speaking about MS Access, which accepts #mm/dd/yyyy#

And personnally, on Access, I would stay well away from using mm/dd/yyy: I think the way Access interprets dates depends on the locale settings in the OS. So what runs on a US English machine may not run on a French system...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Database and date format variable
« Reply #6 on: June 27, 2011, 01:15:54 pm »
Ok, thank you  :)
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018