Luciano Evaristo Guerche

A brazilian geek interested in .NET technologies

About Me

May 2004 - Posts

Visual Basic at the Movies now available for download...
VB at the Movies


Interested in VB at the Movies, but wanted to pull the video files local? Now you can... Click here to go to the download page.

[Via Duncan Mackenzie...]
Why RSS aggregators do not use feed's title atribute from OPML file?
I have tried Bloglines.com (http://www.bloglines.com/public/LucianoEvaristoGuerche), Sauce Reader, Newsgator and some others RSS aggregators and all of them do not use feed's title atribute from OPML file. Why do they go this way? They should at least give user a choice, to decide which title to use, from OPML file or from feed. I prefer having: Microsoft :: Regional Directors Michele Leroux Bustamante - San Diego, California, USA than Microsoft :: Regional Directors dasBlonde What do you folks think about?
I've just read "New Features in VB.NET Part 2 -- Generics"
I have just read New Features in VB.NET Part 2 -- Generics, from O'Reilly Network Newsletter Although I am Visual Basic 6 programmer, I feel C# sintax more understandable...
Finally, I got into Orkut...
Thanks to Frank Arrigo, I am finally in. If you are still out, just let me know and I will see if I can get you in...
An ease way of using ADO Recordset's Filter method to filter a field by multiple values
Yesterday, I needed to filter an ADO Recordset field by multiple values, so I first tried:
'myFilterList = "1,3,4,5"
If myFilterList & vbNullString <> vbNullString Then
    MyRecordset.Filter = "MyField IN (" & myFilterList & ")"
End If
and just found out it did not work because "IN" is not a valid operator for the Filter method. So to workaround this I rewrote code as follow:
'myFilterList = "1,3,4,5"
If myFilterList & vbNullString <> vbNullString Then
    MyRecordset.Filter = "MyField = " & Join(Split(myFilterList, ","), " OR MyField = ")
End If
Tried it with only one value in the list as below and it also worked correctly
'myFilterList = "2"
If myFilterList & vbNullString <> vbNullString Then
    MyRecordset.Filter = "MyField = " & Join(Split(myFilterList, ","), " OR MyField = ")
End If
I have not tried it yet with ADO.NET, but believe the problem with the "IN" operator persists. What do you think about this code. Just drop me a line and let me know your opinion about it.
First post using w.bloggar
After posting a reply to Roy Osherove's Returning to RSS bandit and a couple of requests, I googled a little and found some ways to post to .Text at Desktop Blogging by Scott Watermasysk, the creator of .Text. This moment I am trying w.bloggar, a freeware tool developed by a brazilian guy, Marcelo Cabral. I am also interested in the mentioned plug-in to SharpReader and RSS Bandit, since I am a RSS Bandit user, but could not get to it, since http://www.sharpreader.net/ seems to be unavailable so far.
How to use AVG aggregation function on datetime fields...

Today I have been asked by one of my coworkers how to use AVG aggregation function on datetime fields. She asked it because if you use SELECT AVG(MyTable.MyDateTimeField) FROM MyTable, SQL Server will return Server: Msg 409, Level 16, State 2, Line 1 The average aggregate operation cannot take a datetime data type as an argument.

To workaround this, just change the SQL statement to SELECT CAST(AVG(CAST(MyTable.MyDateTimeField AS float)AS datetime) FROM MyTable and things will work properly.

RE: Separating Date and Time in T-SQL

Reading Erik Porter's post Separating Date and Time in T-SQL, I remembered I have created some SQL Server 2000 functions which deals with such scenario. I am attaching them just below for readers' appreciation.

CREATE FUNCTION dbo.DATEVALUE
(
 @Datetime datetime
)
/*******************************************************************************
 * AUTHOR: Luciano Evaristo Guerche                                            *
 *******************************************************************************/
RETURNS datetime
AS
BEGIN
    RETURN CAST(ROUND(CAST(@Datetime AS float), 0, 1) AS datetime)
END
GO

CREATE FUNCTION dbo.TIMEVALUE
(
 @Datetime datetime
)
/*******************************************************************************
 * AUTHOR: Luciano Evaristo Guerche                                            *
 *******************************************************************************/
RETURNS datetime
AS
BEGIN
    RETURN (@Datetime - CAST(ROUND(CAST(@Datetime AS float), 0, 1) AS datetime))
END
GO

CREATE FUNCTION dbo.DATESERIAL
(
 @YearSerial int,
 @MonthSerial int,
 @DaySerial int
)
RETURNS datetime
AS
BEGIN
    RETURN (CAST(CAST(@YearSerial AS varchar(4)) + '-' + CAST(@MonthSerial AS varchar(2)) + '-' + CAST(@DaySerial AS varchar(2)) AS datetime))
END
GO

CREATE FUNCTION dbo.TIMESERIAL
(
 @HOUR AS int,
 @MINUTE AS int,
 @SECOND AS int,
 @MILLISECOND AS int
)
/*******************************************************************************
 * AUTHOR: Luciano Evaristo Guerche                                            *
 *******************************************************************************/
RETURNS datetime
AS
BEGIN
    RETURN ((@HOUR / 24) + DATEADD(hour, @HOUR % 24, DATEADD(minute, @MINUTE, DATEADD(second, @SECOND, DATEADD(millisecond, @MILLISECOND, 0)))))
END
GO

CREATE FUNCTION dbo.DATETIME_CUSTOM_FORMAT
(
 @INPUT AS datetime = NULL
)
/*******************************************************************************
 * AUTHOR: Luciano Evaristo Guerche                                            *
 *******************************************************************************/
RETURNS varchar(20)
AS
BEGIN
    RETURN (CASE WHEN (ROUND(CAST(@INPUT AS float), 0, 1) * 24) + DATEPART(hour, @INPUT) < 10 THEN '0' ELSE '' END + CAST((ROUND(CAST(@INPUT AS float), 0, 1) * 24) + DATEPART(hour, @INPUT) AS varchar(10)) + ':' +
            RIGHT('00' + CAST(DATEPART(minute, @INPUT) AS varchar(2)), 2) + ':' +
            RIGHT('00' + CAST(DATEPART(second, @INPUT) AS varchar(2)), 2) + '.' +
            RIGHT('000' + CAST(DATEPART(millisecond, @INPUT) AS varchar(3)), 3)
           )
END
GO

More Posts