473,791 Members | 2,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OLEDB and Dates and Timestamps

Am I the only one in the world that selects dates and timestamps with
OLEDB?
V8 of UDB has brought me a big problem.

The PATCH2=24 setting no longer works the way it used to. The
settings of MAPDATEDESCRIBE =1, MAPTIMEDESCRIBE =1, and
MAPTIMESTAMPDES CRIBE=1 allow me to reverse that V8 change, almost.
Before V8, the format of a date column returned in OLEDB was based
upon the regional settings of the client. Now, it returns it in
YYYY-MM-DD. Guess what all my web servers have for their regional
settings! MM-DD-YYYY! Can you imagine the mass hysteria and peasant
land seizure that I am experiencing!

I see no mention of this on the message board. Is there something I
am missing? Does anyone have a slick way of dealing with timestamps,
dates, and times in OLEDB or ADO?

TIA,

Craig Wahlmeier
Senior Technical Administrator - Database Systems
Data-Tronics Corp.
Nov 12 '05 #1
10 7167
Define the datatype of your target variable as a date / timestamp variable;
then you'll get the native format (e.g., for VB6, you get a Date). You
problem only arises as your'e attempting to convert to a string
representation.

"Craig Wahlmeier" <cw********@dat a-tronics.com> wrote in message
news:ac******** *************** ***@posting.goo gle.com...
Am I the only one in the world that selects dates and timestamps with
OLEDB?
V8 of UDB has brought me a big problem.

The PATCH2=24 setting no longer works the way it used to. The
settings of MAPDATEDESCRIBE =1, MAPTIMEDESCRIBE =1, and
MAPTIMESTAMPDES CRIBE=1 allow me to reverse that V8 change, almost.
Before V8, the format of a date column returned in OLEDB was based
upon the regional settings of the client. Now, it returns it in
YYYY-MM-DD. Guess what all my web servers have for their regional
settings! MM-DD-YYYY! Can you imagine the mass hysteria and peasant
land seizure that I am experiencing!

I see no mention of this on the message board. Is there something I
am missing? Does anyone have a slick way of dealing with timestamps,
dates, and times in OLEDB or ADO?

TIA,

Craig Wahlmeier
Senior Technical Administrator - Database Systems
Data-Tronics Corp.

Nov 12 '05 #2
Mark,

Thank you for your reply. We are using VBScript inside of ASP pages.
As you know, VBScript is untyped like REXX. IBM has really made this
V8 conversion a mess! To add insult to injury, I just noticed that
the MAPTIMESTAMPDES CRIBE=1 returns a timestamp that is missing a dash,
e.g. 2001-01-01 00.00.00.000000 .

I opened PMR 46073,370 last November. I took me a week to convince
the rep that you could indeed select a timestamp via OLEDB! I figured
out the MAPDATEDESCRIBE myself and closed the PMR. I guess I will
open another. I still cannot believe that we are the only ones
accessing DB2 via OLEDB in Active Server Pages and having a problem.

Thanks,

Craig Wahlmeier
Senior Technical Administrator - Database Systems
Data-Tronics Corp.
Nov 12 '05 #3
We always select dates as CHAR(MyDateFiel d) and then manipulate in the
ASP code,
as our DBAs like to store dates that have not happened - i.e.
termination_dat e
for an active employee as 0001-01-01, which gives ADO fits unless you
fetch as a charactor string. Have NEVER had any luck manipulating
timestamps from DB2 via ADO. Can compare timestamps as in ... where
A.ts = B.ts, but never able to execute a query, save ts in an ASP
variable and use again in a query via ASP/ADO...

Phil J.

Mark,

Thank you for your reply. We are using VBScript inside of ASP pages.
As you know, VBScript is untyped like REXX. IBM has really made this
V8 conversion a mess! To add insult to injury, I just noticed that
the MAPTIMESTAMPDES CRIBE=1 returns a timestamp that is missing a dash,
e.g. 2001-01-01 00.00.00.000000 .

I opened PMR 46073,370 last November. I took me a week to convince
the rep that you could indeed select a timestamp via OLEDB! I figured
out the MAPDATEDESCRIBE myself and closed the PMR. I guess I will
open another. I still cannot believe that we are the only ones
accessing DB2 via OLEDB in Active Server Pages and having a problem.

Thanks,

Craig Wahlmeier
Senior Technical Administrator - Database Systems
Data-Tronics Corp.

Nov 12 '05 #4
I wish you'd said VBScript / ASP up front; I assumed you were using a
compiled language. VBScript is very much a mess. But I'd still like to see
your ADO code for defining the field.

"Craig Wahlmeier" <cw********@dat a-tronics.com> wrote in message
news:ac******** *************** ***@posting.goo gle.com...
Mark,

Thank you for your reply. We are using VBScript inside of ASP pages.
As you know, VBScript is untyped like REXX. IBM has really made this
V8 conversion a mess! To add insult to injury, I just noticed that
the MAPTIMESTAMPDES CRIBE=1 returns a timestamp that is missing a dash,
e.g. 2001-01-01 00.00.00.000000 .

I opened PMR 46073,370 last November. I took me a week to convince
the rep that you could indeed select a timestamp via OLEDB! I figured
out the MAPDATEDESCRIBE myself and closed the PMR. I guess I will
open another. I still cannot believe that we are the only ones
accessing DB2 via OLEDB in Active Server Pages and having a problem.

Thanks,

Craig Wahlmeier
Senior Technical Administrator - Database Systems
Data-Tronics Corp.

Nov 12 '05 #5
Mark,

Below is some vbscript. On a V7 fp10 client I get this output -
ts = 2001-01-01-00.00.00.000000
dt = 01/01/2001

On a V8 fp4 client, I get this output -
ts = 01/01/2001
dt = 01/01/2001

Both db2cli.ini files have this for the Sample database -
[sample]
DBALIAS=SAMPLE
LOBMAXCOLUMNSIZ E=1048575
LONGDATACOMPAT= 1
PATCH1=132096
PATCH2=24,6
SYSSCHEMA=SYSIB M
TXNISOLATION=1

If I add MAPTIMESTAMPDES CRIBE=1 to the V8 client, the output looks
like this -
ts = 2001-01-01 00:00:00.000000
dt = 01/01/2001

If the date column has '0001-01-01', then you have to either add
MAPDATEDESCRIBE =1, or take Phil's advice at use the CHAR funtion. I
think Phil's advice is better because the MAPDATEDESCRIBE =1 causes
this output -
ts = 2001-01-01 00:00:00.000000
dt = 2001-01-01

The date field format is no longer based on your regional settings.

Thanks for your input. Here is the script

Craig
<Job id="DB2 SQL Tester">

<script language="VBScr ipt">
Option Explicit
Const ForReading = 1
Const adUseClient = 3
Const adLockReadOnly = 1
Const adOpenForwardOn ly = 0

dim rstDB2
dim sSQL
dim cnnDB2
dim sDB2DBname
dim sDB2UserID
dim sDB2Password

sDB2DBname = "SAMPLE"
sDB2UserID = "xxxxxxx"
sDB2Password = "yyyyyy"

Set cnnDB2 = WScript.CreateO bject("ADODB.Co nnection")
Set rstDB2 = WScript.CreateO bject("ADODB.Re cordset")

sSQL = "Select COL1, COL2 FROM DTC.TABLE1 "
cnnDB2.Provider = "IBMDADB2;d sn=" & sDB2DBname & ";uid=" &
sDB2UserID & ";pwd=" & sDB2Password
cnnDB2.CursorLo cation = adUseClient
cnnDB2.Open
rstDB2.Open sSQL,cnnDB2,adO penForwardOnly, adLockReadOnly
wscript.echo ("ts = " & rstDB2("COL1"))
wscript.echo ("dt = " & rstDB2("COL2"))

rstDB2.close
cnnDB2.close
set cnnDB2 = Nothing
set rstDB2 = Nothing

</Script>
</Job>
Nov 12 '05 #6
Try defining the target field as datetime, rather than leaving it to default
(to a string). That way, you'll have a VBA [OLE] Date type rather than a
string, which you can format however you like using the VBA Format$ function
and related routines.

"Craig Wahlmeier" <cw********@dat a-tronics.com> wrote in message
news:ac******** *************** ***@posting.goo gle.com...
<Job id="DB2 SQL Tester">

<script language="VBScr ipt">
Option Explicit
Const ForReading = 1
Const adUseClient = 3
Const adLockReadOnly = 1
Const adOpenForwardOn ly = 0

dim rstDB2
dim sSQL
dim cnnDB2
dim sDB2DBname
dim sDB2UserID
dim sDB2Password

sDB2DBname = "SAMPLE"
sDB2UserID = "xxxxxxx"
sDB2Password = "yyyyyy"

Set cnnDB2 = WScript.CreateO bject("ADODB.Co nnection")
Set rstDB2 = WScript.CreateO bject("ADODB.Re cordset")

sSQL = "Select COL1, COL2 FROM DTC.TABLE1 "
cnnDB2.Provider = "IBMDADB2;d sn=" & sDB2DBname & ";uid=" &
sDB2UserID & ";pwd=" & sDB2Password
cnnDB2.CursorLo cation = adUseClient
cnnDB2.Open
rstDB2.Open sSQL,cnnDB2,adO penForwardOnly, adLockReadOnly
wscript.echo ("ts = " & rstDB2("COL1"))
wscript.echo ("dt = " & rstDB2("COL2"))

rstDB2.close
cnnDB2.close
set cnnDB2 = Nothing
set rstDB2 = Nothing

</Script>
</Job>

Nov 12 '05 #7
Mark,

You lost me. VBScript is an untyped language...

Craig
Nov 12 '05 #8
In ADO, you define how your recordset's fields tie up by using statements:
myRS.Fields.App end name, type, defined_size, attributes
In your case, you would specify type as adDate.

Since you don't do this yourself, you're getting the default bindings. These
are often not what you want; in your case, they obviously aren't, as you've
complained about it.

Note: we're not talking about declaring VBScript variables, we're talking
about declaring the bindings between the ADO source and the data consumer
(your VBScript), as processed by ADO. Also. VBScript typing is irrelevant as
for data access you're using ADO's recordset to access the field:
myRS!FieldName.

To ask ADO to give you what you want, you have to tell ADO how to do it.
Otherwise it second-guesses, based on the database content (which is fine
for simple types like integers or strings).

"Craig Wahlmeier" <cw********@dat a-tronics.com> wrote in message
news:ac******** *************** ***@posting.goo gle.com...
Mark,

You lost me. VBScript is an untyped language...

Craig

Nov 12 '05 #9
I finally got some relief from IBM. I opened pmr 85254,370. If I
apply V8 fixpak 5 to both the client and the server, add patch2=24,33
and maptimestampdes cribe=1 to the db2cli.ini, my problem is fixed.
(With one exception.) I don't know if the patch1=131072 is also
required, but I have it.

Now, my date fields are observing the regional settings of my client.
My timestamp fields are displaying as true timestamps. The only
problem I am left with concerns date fields containing 0001-01-01.
Those cause ado/oledb to trap. I could add a mapdatedescribe =1 to fix
that error. But, that changes my date layout away from my regional
settings to yyyy-mm-dd. So, I will be forced to find all the queries
that could be affected and add a CHAR function to the SQL.

Thanks for all your replies. We plan to start using the CHAR function
for date and timestamp columns in all our queries in the future. I
don't know what IBM tests back at the lab, but it isn't OLEDB.

Thanks,

Craig Wahlmeier
Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2640
by: Sims | last post by:
Hi, I have a field in my DB that saves the date/time as a integer. I get the time on my server using the time() function. now, moving away from php and looking at (My)SQL only. If I use functions like DATE() or NOW(), I don't get a Unix value, (but rather a formatted date). So I cannot use those functions to check against my saved value.
3
3197
by: jrc4728 | last post by:
I have a MySQL table with the date stored in three fields as string values like this. (sorry, its imported data) str_yy str_dd str_mm ------------------------ 05 01 04 05 02 04 and so on.
8
1763
by: Angelos | last post by:
What do you think is the best way to store Dates into a database ? If you want to keep logs or buckups.... I am using date('dmYHis') but I doesn't work really well ... Is it better to use date(U) ? Any suggestions ? And if you can let me know how you can Display that date back in the Screen
1
2993
by: fnord | last post by:
I'm in a bit of a mess here, trying to deal with some timestamp issues. I need to select items from a database with a datetime timestamp: 0000-00-00 00:00:00 I need to select these items based on several different criteria, for which I will use separate select statements, but some of them are a bit confusing.
2
3966
by: p175 | last post by:
People, I have an ESE 8.2.2 database running on win2k server . I need to do some system testing that requires I reset the dates back a couple of years then progressivily move it forward to current date. The last time I tried this the database got very upset and the date functions such as DAYOFWEEK_ISO, YEAR, WEEK, QUARTER etc got all screwed up and failed. I subsequently had to completely drop the database, recreate from scratch and...
3
1850
by: MaRCeLO PeReiRA | last post by:
Hi Guys, I am in troubles with some dates. "I need to know the difference, in days, between two dates." Well, if the difference is less than a month, so I could use:
9
3226
by: Bosconian | last post by:
I must be having a brain freeze because I can't figure out how to display dates older than 1970. I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06). I'd like to display as "April 4, 1955". I've tried using date("F j, Y"), but only get "December 31, 1969". I'm using PHP 4.3.8. Any suggestions would be appreciated.
2
18344
by: ameshkin | last post by:
Hi GUys, Im trying to compare two dates in MYSQL. But its not treating the dates as numbers, but as strings. I try using strtotime but that did not work. Basically, if the last comment is newer than the last user login, then I need for a message to pop up and say New Comments. If not, then no new comments. The area of this code which is not working is at the bottom.
2
2197
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed upon a file, but it ends up not being able to display the date (probably an Windows Explorer specific issue). (2) I'm looking for for ways to store dates and process dates (dates only). This probably ends up as a database specific issue, so I'm...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9995
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.