From: amdrit on
I am looking for a strategy to localize the date as we recieve if from the
database. All dates are stored on the server based on the database server's
local time.

Most of the SQL statements are inline and ad-hoc using ado and vb6. What I
am hoping to avoid is adding date manipulation logic in those inline sql
statements. Since some of the recordsets are data bound to repeaters or
grids, I cannot imagine looping over the recordset updating the date -
besides the sheer waste of processor time on the client side.

It looks like my best option atm would be to create a custom fucntion on,
say, the sql server. That would adjust the datetime for me, it just seems
like overkill and that there is a better way.

func_AdjustDate(gmt)

sql = "Select func_AdjustDate(" & GetLocalGMT & ", MyDate) from MyTable
Order By func_AdjustDate(" & GetLocalGMT & ", MyDate) Desc;"

The other option would be to perform a dateadd in the sql

sql = "Select DateAdd(h," & GetLocalGMT & ", MyDate) from MyTable Order By
DateAdd(h," & GetLocalGMT & ", MyDate) Desc; "

Is there a way to instruct the ADO library to adjust dates coming from a
database server accordingly? There are litterally 100's if not 100's of sql
statements in this very old product. I'd rather not regression test the
entire suite for this change - rather all sql statements are executed
through a single FetchData(sqlstmt as string) function call.

Here I could loop through all recordsets and update the dates accordingly
before passing them back to the caller. It would seem to be a waste to loop
through all the recodsets this way.

One can hope, can't he?


From: Phil Hunt on
Use a default date on the column, but it only works on insert.
Or use a trigger to update the field.


"amdrit" <amdrit(a)hotmail.com> wrote in message
news:%23WopsI76KHA.3504(a)TK2MSFTNGP05.phx.gbl...
>I am looking for a strategy to localize the date as we recieve if from the
>database. All dates are stored on the server based on the database
>server's local time.
>
> Most of the SQL statements are inline and ad-hoc using ado and vb6. What
> I am hoping to avoid is adding date manipulation logic in those inline sql
> statements. Since some of the recordsets are data bound to repeaters or
> grids, I cannot imagine looping over the recordset updating the date -
> besides the sheer waste of processor time on the client side.
>
> It looks like my best option atm would be to create a custom fucntion on,
> say, the sql server. That would adjust the datetime for me, it just seems
> like overkill and that there is a better way.
>
> func_AdjustDate(gmt)
>
> sql = "Select func_AdjustDate(" & GetLocalGMT & ", MyDate) from MyTable
> Order By func_AdjustDate(" & GetLocalGMT & ", MyDate) Desc;"
>
> The other option would be to perform a dateadd in the sql
>
> sql = "Select DateAdd(h," & GetLocalGMT & ", MyDate) from MyTable Order By
> DateAdd(h," & GetLocalGMT & ", MyDate) Desc; "
>
> Is there a way to instruct the ADO library to adjust dates coming from a
> database server accordingly? There are litterally 100's if not 100's of
> sql statements in this very old product. I'd rather not regression test
> the entire suite for this change - rather all sql statements are executed
> through a single FetchData(sqlstmt as string) function call.
>
> Here I could loop through all recordsets and update the dates accordingly
> before passing them back to the caller. It would seem to be a waste to
> loop through all the recodsets this way.
>
> One can hope, can't he?
>


From: Nobody on
"amdrit" <amdrit(a)hotmail.com> wrote in message
news:%23WopsI76KHA.3504(a)TK2MSFTNGP05.phx.gbl...
>I am looking for a strategy to localize the date as we recieve if from the
>database. All dates are stored on the server based on the database
>server's local time.

See "format objects" in MSDN. There is Format/Unformat events to allow you
to translate field values back and forth between the DB and bound controls.
One example, is to translate 1, 2, 3 to "Red", Green", "Blue", and so on.