Date Format
Posted in 2000
Topics: Connectivity: ODBC / JDBC / .NET
Hi Is there a possibility to enter Date datatypes in differnet ways in the Database? I don't want to use the environment variables, because I have no influence in the settings on the end-maschine. What I'm looking for is something like the TO_DATE() funktion in ORACLE. The problem that I have is, when inserting dates in the Table using jdbc I have to use the format 'YYYY.MM.DD' but if I use a direct input I have to use 'MM.DD.YYYY'. It's the same Database, the same user, the same table, just accessed direct or with jdbc. Thanks in Advance.... Frank
Frank Wehrle wrote: > > Hi > > Is there a possibility to enter Date datatypes in differnet ways in the > Database? > I don't want to use the environment variables, because I have no > influence in the settings on the end-maschine. > > What I'm looking for is something like the TO_DATE() funktion in ORACLE. > > The problem that I have is, when inserting dates in the Table using jdbc > I have to use the format 'YYYY.MM.DD' but if I use a direct input I have > to use 'MM.DD.YYYY'. It's the same Database, the same user, the same > table, just accessed direct or with jdbc. You can use the UNIX/C function getdate() to parse a text date string it is rather flexible but its operation also depends on an environment variable DATEMSK to identify a list of files containing enterpretation masks. I have a version of getdate() I enhanced from the EMACS source. It was incorporated into emacs from a third party who placed it in public domain so it is not GLIB copyleft controlled. My function parses both dates and times down to the microsecond (1/(10^6)) so it can be used for DATETIME values also and recognizes both hard dates (including classic DATETIME, US, and Euro date/time formats) and soft dates (like yesterday, 3 days ago, last week, 18 hours ago, etc). Get my package datelib_ak from the IIUG Software Repository. The package includes a function to take a freeform string in, call my getdate function, and convert to standard DATETIME/ANSI format. It would be trivial to convert to DATE format in the standard format you want instead. Art S. Kagel