Skip to main content

Posts

Showing posts from January, 2009

Time range in SQL Server

Sometimes we encounter situations wherein we need to include in our query, a time range given that the only fields in the SQL server database is the start time and the duration: StartTime Duration 09:30:00 AM 60 07:30:00 AM 90 *The table name in this example is tbl_UserSchedule We sometimes want to show it in a form of a time range just like looking at a schedule: Schedule 09:30:00 AM - 10:30:00 AM 07:30:00 AM - 09:00:00 AM The following SQL statement does the job (although not quite optimized): SELECT CONVERT(char(9), StartTime, 108) + CASE WHEN StartTime > '11:59:59 PM' THEN 'PM' ELSE 'AM' END + ' - ' + CONVERT(char(9), DATEADD(minute, Duration, StartTime), 108) + CASE WHEN DateAdd(minute, Duration, StartTime) > '11:59:59 PM' THEN 'PM' ELSE 'AM' END FROM tbl_UserSchedule

Create a CNAME record at godaddy

These instructions are from blogger's site. However, you have to have both domain and hosting account with Godaddy. Total DNS will be empty otherwise. GoDaddy.com Log in to your account at www.godaddy.com . Open the Domains tab and select My Domain Names . You'll be directed to the Domain Manager page. Click the domain that you'd like to use with your blog. Click the Total DNS Control And MX Records link at the bottom of the section entitled Total DNS . Click Add New CNAME Record in the box labelled CNAMES (aliases) . If you've already created a CNAME record for your blog's address, click the pencil icon next to the existing CNAME record. For the Name , enter only the subdomain of the address you want to use for your blog. For example, if you picked www.mydomain.com as your address, enter www here. Enter ghs.google.com as the Host Name . Specify a TTL or use the default setting of 1 hour. Click OK , and then click OK again. Keep up with the la

Using events/delegates in C#

This example demonstrates the use of delegate in C#. The example consists of a class named Class1.cs and a form named Form1. The class has an attribute named Property1 and implements the use of delegate by having an event fired when the property changes. The Form contains a textbox and a button. When the user clicks the button, it initializes the class and sets its attribute (Property1) to "testProperty". The value set will automatically be displayed at the textbox once the event fires. //Class1.cs //*********************************************************************************** using System; using System.Collections.Generic; using System.Text; namespace WindowsApplication1 { public class Class1 { public delegate void ValueSet(); public event ValueSet OnValueSet; private string _property1; public string Property1 { get { return _property1; } set { _property1 = value; OnValueSet();

Next Trade Expo

I wonder when the next trade expo here in Davao will be. I wasn't able to attend last time as I was too preoccupied with everything else. The trade expo last year was a success. Many companies participated and there were exhibits. The expo was held at the Davao Convention Center last October 23-25, 2008. It catered the needs of and provided opportunities for the Small and Medium Enterprises. A few factors entice me to attending trade expos. The first would be the wide range of opportunities for business. I have been given a chance to become an entrepreneur for a few years and it wasn't easy. My partners and I had the enthusiasm but still didn't quite succeed the way we wanted to. Marketing is one way to have it. Through trade expos, a business can build linkages to other businesses and potential customers. It is a great way for businesses to "socialize". The second factor that attract my attention to these expos are the exhibits. We can get great ideas for our own

Number to Text in Excel that can handle more than 3 decimal places

follow the instructions from my previous post . paste the following code instead of the new one. Option Explicit '**************** ' Main Function * '**************** Function SpellNumber(ByVal MyNumber) Dim Temp, WholeNumberText, DecimalText Dim DecimalPlace, Count ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion " Place(5) = " Trillion " ' String representation of amount. MyNumber = Trim(Str(MyNumber)) ' Position of decimal place 0 if none. DecimalPlace = InStr(MyNumber, ".") ' Convert cents and set MyNumber to dollar amount. If DecimalPlace > 0 Then DecimalText = Left(Mid(MyNumber, DecimalPlace + 1), DecimalPlace - 1) '& Format(0, String(DecimalPlace - 1, "0")) MyNumber = Trim(Left(MyNumber, DecimalPlace - 1)) End If Count = 1 Do While MyNumber <> "" Temp = GetHundreds(Right(MyNumber, 3)) If Temp <> "" Then WholeN

Using MySQL with Visual Basic .Net

Before you use this code, here are my assumptions: You have background on database management system You know how to create a database in mysql You know how to add tables to the database You are familiar with Visual Basic .Net Things needed/installed: MySQL Connector Microsoft Visual Basic Express 2008 (Since this is what I'm using right now. You can use Visual Basic Express 2005 or the full version included in the Microsoft Visual Studio Package) MySQL Editor (I'm using WAMP's phpMyAdmin) Things to do: Create a database in MySQL with at least 1 table. I'm using the following in this sample: Database Name : Contacts Table Name : ContactInformation Fields : Id (int, autoIncrement), Name (varchar(64)), ContactNumber (varchar(20)) Sample Contents: Id Name ContactNumber 1 John Doe (yyy) yyy-yyyy 2 Jane Doe