Search This Blog

Saturday, June 29, 2013

SYBASE: DATETIME format conversion styles

SYNTAX :
convert (datatype [(length) | (precision[, scale])]
        [null | not null], expression [, style])

Without century (yy)
With century (yyyy)
Standard
Output
Key “mon” indicates a month spelled out, “mm” the month number or minutes. “HH ”indicates a 24-hour clock value, “hh” a 12-hour clock value. The last row, 23, includes a literal “T” to separate the date and time portions of the format.
-
0 or 100
Default
mon dd yyyy hh:mm AM (or PM)
1
101
USA
mm/dd/yy
2
2
SQL standard
yy.mm.dd
3
103
English/French
dd/mm/yy
4
104
German
dd.mm.yy
5
105
dd-mm-yy
6
106
dd mon yy
7
107
mon dd, yy
8
108
HH:mm:ss
-
9 or 109
Default + milliseconds
mon dd yyyy hh:mm:sss AM (or PM)
10
110
USA
mm-dd-yy
11
111
Japan
yy/mm/dd
12
112
ISO
yy/mm/dd
13
113
yy/mm/dd
14
114
yy/mm/dd
14
114
hh:mi:ss:mmmAM(or PM)
15
115
dd/yy/mm
16
116
mon dd yy HH:mm:ss
17
117
hh:mmAM
18
118
HH:mm
19
119
hh:mm:ss:zzzAM
20
120
hh:mm:ss:zzz
21
121
yy/mm/dd
22
122
yy/mm/dd
23
123
yyyy-mm-ddTHH:mm:ss

Some Examples:
SELECT CONVERT(CHAR(50), DATETIME('2009-11-03 11:10:42.033189'), 136) FROM iq_dummy returns 11:10:42.033189AM
SELECT CONVERT(CHAR(50), NOW(), 137) FROM iq_dummy returns 14:54:48.794122
The following statements illustrate the use of the format style 365, which converts data of type DATE and DATETIME to and from either string or integer type data:
CREATE TABLE tab
   (date_col DATE, int_col INT, char7_col CHAR(7));
INSERT INTO tab (date_col, int_col, char7_col)
   VALUES (‘Dec 17, 2004’, 2004352, ‘2004352’);
SELECT CONVERT(VARCHAR(8), tab.date_col, 365) FROM tab; returns ‘2004352’
SELECT CONVERT(INT, tab.date_col, 365) from tab; returns 2004352
SELECT CONVERT(DATE, tab.int_col, 365) FROM TAB; returns 2004-12-17
SELECT CONVERT(DATE, tab.char7_col, 365) FROM tab; returns 2004-12-17

UNIX: vi Editor

The vi editor is available most of the Unix systems. vi can be used from any type of terminal because it does not depend on arrow keys and function keys--it uses the standard alphabetic keys for commands. vi is short form for "vi"sual editor. It displays a window into the file being edited that shows 24 lines of text. vi lets you add, change, and delete text, but does not provide such formatting capabilities as centering lines or indenting paragraphs. vi has many other commands and options not described here. You cannot remember all the commands until or unless you try out hands on with the commands.
You may use vi to open an already existing file by typing
      vi your_file
where "your_file" is the name of the existing file. If the file is not in your current directory, you must use the full pathname.
Or you may create a new file by typing
      vi new_file
where "new_file" is the name you wish to give the new file.
On-screen, you will see blank lines, each with a tilde (~) at the left, and a line at the bottom giving the name and status of the new file:
~
      "new_file" [New file]
vi has two modes:
  • command mode
  • insert mode
In command mode, the letters of the keyboard perform editing functions (like moving the cursor, deleting text, etc.). To enter command mode, press the escape <Esc> key.
In insert mode, the letters you type form words and sentences. vi starts up in command mode.
In order to begin entering text in this empty file, you must change from command mode to insert mode. To do this, type
      i
Nothing appears to change, but you are now in insert mode and can begin typing text. In general, vi's commands do not display on the screen and do not require the Return key to be pressed.
Type a few short lines and press <Return> at the end of each line. If you type a long line, you will notice the vi does not word wrap, it merely breaks the line unceremoniously at the edge of the screen.
If you make a mistake, pressing <Backspace> or <Delete> may remove the error, depending on your terminal type.
To delete a character from a file, move the cursor until it is on the incorrect letter, then type
      x
The character under the cursor disappears. To remove four characters (the one under the cursor and the next three) type
     4x
To delete the character before the cursor, type
      X (uppercase)
To delete a word, move the cursor to the first letter of the word, and type
      dw
This command deletes the word and the space following it.
To delete three words type
       3dw
To delete from the cursor position to the end of the line, type
       D (uppercase)
To delete a whole line, type
       dd
The cursor does not have to be at the beginning of the line. Typing dd deletes the entire line containing the cursor and places the cursor at the start of the next line. To delete two lines, type
       2dd
To replace one character with another:
  1. Move the cursor to the character to be replaced.
  2. Type letter r
  3. Type the replacement character.
The new character will appear, and you will still be in command mode.
To replace one word with another, move to the start of the incorrect word and type
     cw
The last letter of the word to be replaced will turn into a $. You are now in insert mode and may type the replacement. The new text does not need to be the same length as the original. Press <Esc> to get back to command mode. To replace three words, type
     3cw
To change text from the cursor position to the end of the line:
  1. Type C (uppercase).
  2. Type the replacement text.
  3. Press <Esc>.
To add text to the end of a line:
  1. Position the cursor on the last letter of the line.
  2. Type a
  3. Enter the new text.
We use this very often insert text is more oftenly used than this
To insert a blank line below the current line, type
     o (lowercase)
     
To insert a blank line above the current line, type
     O (uppercase)
To join two lines together:
  1. Put the cursor on the first line to be joined.
  2. Type J
To join three lines together:
  1. Put the cursor on the first line to be joined.
  2. Type 3J
Undo (Ctrl + Z)
To undo your most recent edit, type
     u
To undo all the edits on a single line, type
     U (uppercase)
Note: Undoing all edits on a single line only works as long as the cursor stays on that line. Once you move the cursor off a line, you cannot use U to restore the line.
To move the cursor to another position, you must be in command mode. If you have just finished typing text, you are still in insert mode. Go back to command mode by pressing <Esc>. If you are not sure which mode you are in, press <Esc> once or twice until you hear a beep. When you hear the beep, you are in command mode.
There are shortcuts to move more quickly though a file. All these work in command mode.
     Key            description
     ---            --------
     h        left one space
     j        down one line
     k        up one line
     l        right one space
       w            forward word by word
     b            backward word by word
     $            to end of line
     0 (zero)     to beginning of line
     H            to top line of screen
     M            to middle line of screen
     L            to last line of screen
     G            to last line of file
     1G           to first line of file
     <Control>f   scroll forward one screen
     <Control>b   scroll backward one screen
     <Control>d   scroll down one-half screen
     <Control>u   scroll up one-half screen
To move quickly by searching for text, while in command mode:
  1. Type / (slash).
  2. Enter the text to search for.
  3. Press <Return>.
The cursor moves to the first occurrence of that text.
To repeat the search in a forward direction, type
     n
To repeat the search in a backward direction, type
     N
To move to a specific line nuber u can type
       :
To save the edits you have made, but leave vi running and your file open:
  1. Press <Esc>.
  2. Type :w
  3. Press <Return>.
CLOSE FILE
To close vi, and discard any changes your have made since last saving:
  1. Press <Esc>.
  2. Type :q!
    3.   Press <Return>.

Saturday, June 22, 2013

EXCEL: Know About Hyperlink() Function.

A hyperlink is a link from a document that opens another page or file when you click it. The destination is frequently another Web page, but it can also be a picture, or an e-mail address, or a program. The hyperlink itself can be text or a picture.
How hyperlinks are used
You can use hyperlinks to do the following:
·         Navigate to a file or Web page that you plan to create in the future
·         Send an e-mail message
When you point to text or a picture that contains a hyperlink, the pointer becomes a hand , indicating that the text or picture is something that you can click.
What a URL is and how it works
http://example.microsoft.com/news.htm
file://ComputerName/SharedFolder/FileName.htm

 Protocol used (http, ftp, file)
 Web server or network location
 Path
 File name

Absolute and relative hyperlinks
A relative URL has one or more missing parts. The missing information is taken from the page that contains the URL. For example, if the protocol and Web server are missing, the Web browser uses the protocol and domain, such as .com, .org, or .edu, of the current page.
It is common for pages on the Web to use relative URLs that contain only a partial path and file name. If the files are moved to another server, any hyperlinks will continue to work as long as the relative positions of the pages remain unchanged. For example, a hyperlink on Products.htm points to a page named apple.htm in a folder named Food; if both pages are moved to a folder named Food on a different server, the URL in the hyperlink will still be correct.
In a Microsoft Office Excel workbook, unspecified paths to hyperlink destination files are by default relative to the location of the active workbook. You can set a different base address to use by default so that each time that you create a hyperlink to a file in that location, you only have to specify the file name, not the path, in the Insert Hyperlink dialog box.

Create a hyperlink to a new file
1.       On a worksheet, click the cell where you want to create a hyperlink.
 Tip   You can also select an object, such as a picture or an element in a chart, that you want to use to represent the hyperlink.
On the Insert tab, in the Links group, click Hyperlink.
 Tip    You can also right-click the cell or graphic and then click Hyperlink on the shortcut menu, or you can press CTRL+K.
2.       Under Link to, click Create New Document.
3.       In the Name of new document box, type a name for the new file.
 Tip   To specify a location other than the one shown under Full path, you can type the new location preceding the name in the Name of new document box, or you can click Change to select the location that you want and then click OK.
4.       Under When to edit, click Edit the new document later or Edit the new document now to specify when you want to open the new file for editing.
5.       In the Text to display box, type the text that you want to use to represent the hyperlink.
6.       To display helpful information when you rest the pointer on the hyperlink, click ScreenTip, type the text that you want in the ScreenTip text box, and then click OK.
Create a hyperlink to an existing file or Web page
1.       On a worksheet, click the cell where you want to create a hyperlink.
 Tip   You can also select an object, such as a picture or an element in a chart, that you want to use to represent the hyperlink.
On the Insert tab, in the Links group, click Hyperlink.
 Tip    You can also right-click the cell or object and then click Hyperlink on the shortcut menu, or you can press CTRL+K.
2.       Under Link to, click Existing File or Web Page.
3.       Do one of the following:
·         To select a file, click Current Folder, and then click the file that you want to link to.
 Tip   You can change the current folder by selecting a different folder in the Look in list.
·         To select a Web page, click Browsed Pages and then click the Web page that you want to link to.
·         To select a file that you recently used, click Recent Files, and then click the file that you want to link to.
·         To enter the name and location of a known file or Web page that you want to link to, type that information in the Address box.
·         To locate a Web page, click Browse the Web , open the Web page that you want to link to, and then switch back to Office Excel without closing your browser.
4.       If you want to create a hyperlink to a specific location in the file or on the Web page, click Bookmark, and then double-click the bookmark (bookmark: A location or selection of text in a file that you name for reference purposes. Bookmarks identify a location within your file that you can later refer or link to.) that you want.
 Note   The file or Web page that you are linking to must have a bookmark.
5.       In the Text to display box, type the text that you want to use to represent the hyperlink.
6.       To display helpful information when you rest the pointer on the hyperlink, click ScreenTip, type the text that you want in the ScreenTip text box, and then click OK.

Create a hyperlink to a specific location in a workbook
1.       To use a name, you must name the destination cells in the destination workbook.

Name box
3.       In the Name box, type the name for the cells, and then press ENTER.
 Note   Names cannot contain spaces and must begin with a letter.
 Tip   You can also select an object, such as a picture or an element in a chart, that you want to use to represent the hyperlink.
On the Insert tab, in the Links group, click Hyperlink.
 Tip    You can also right-click the cell or object and then click Hyperlink on the shortcut menu, or you can press CTRL+K.
3.       Under Link to, do one of the following:
·         To link to a location in your current workbook, click Place in This Document.
·         To link to a location in another workbook, click Existing File or Web Page, locate and select the workbook that you want to link to, and then click Bookmark.
4.       Do one of the following:
·         In the Or select a place in this document box, under Cell Reference, click the worksheet that you want to link to, type the cell reference in the Type in the cell reference box, and then click OK.
·         In the list under Defined Names, click the name that represents the cells that you want to link to, and then click OK.
5.       In the Text to display box, type the text that you want to use to represent the hyperlink.
6.       To display helpful information when you rest the pointer on the hyperlink, click ScreenTip, type the text that you want in the ScreenTip text box, and then click OK.

Create a custom hyperlink by using the HYPERLINK function
You can use the HYPERLINK function to create a hyperlink that opens a document that is stored on a network server, an intranet (intranet: A network within an organization that uses Internet technologies (such as the HTTP or FTP protocol). By using hyperlinks, you can explore objects, documents, pages, and other destinations on the intranet.), or the Internet. When you click the cell that contains the HYPERLINK function, Excel opens the file that is stored at the location of the link.
Syntax
HYPERLINK(link_location,friendly_name)
Link_location     is the path and file name to the document to be opened as text. Link_location can refer to a place in a document — such as a specific cell or named range in an Excel worksheet or workbook, or to a bookmark in a Microsoft Word document. The path can be to a file stored on a hard disk drive, or the path can be a universal naming convention (UNC) path on a server (in Microsoft Excel for Windows) or a Uniform Resource Locator (URL (Uniform Resource Locator (URL): An address that specifies a protocol (such as HTTP or FTP) and a location of an object, document, World Wide Web page, or other destination on the Internet or an intranet, for example: http://www.microsoft.com/.)) path on the Internet or an intranet.
·         Link_location can be a text string enclosed in quotation marks or a cell that contains the link as a text string.
·         If the jump specified in link_location does not exist or cannot be navigated, an error appears when you click the cell.
Friendly_name     is the jump text or numeric value that is displayed in the cell. Friendly_name is displayed in blue and is underlined. If friendly_name is omitted, the cell displays the link_location as the jump text.
·         Friendly_name can be a value, a text string, a name, or a cell that contains the jump text or value.
·         If friendly_name returns an error value (for example, #VALUE!), the cell displays the error instead of the jump text.
Examples
The following example opens a worksheet named Budget Report.xls that is stored on the Internet at the location named example.microsoft.com/report and displays the text "Click for report":
=HYPERLINK("http://example.microsoft.com/report/budget report.xls", "Click for report")
The following example creates a hyperlink to cell F10 on the worksheet named Annual in the workbook Budget Report.xls, which is stored on the Internet at the location named example.microsoft.com/report. The cell on the worksheet that contains the hyperlink displays the contents of cell D1 as the jump text:
=HYPERLINK("[http://example.microsoft.com/report/budget report.xls]Annual!F10", D1)
The following example creates a hyperlink to the range named DeptTotal on the worksheet named First Quarter in the workbook Budget Report.xls, which is stored on the Internet at the location named example.microsoft.com/report. The cell on the worksheet that contains the hyperlink displays the text "Click to see First Quarter Department Total":
=HYPERLINK("[http://example.microsoft.com/report/budget report.xls]First Quarter!DeptTotal", "Click to see First Quarter Department Total")
To create a hyperlink to a specific location in a Microsoft Word document, you must use a bookmark to define the location you want to jump to in the document. The following example creates a hyperlink to the bookmark named QrtlyProfits in the document named Annual Report.doc located at example.microsoft.com:
=HYPERLINK("[http://example.microsoft.com/Annual Report.doc]QrtlyProfits", "Quarterly Profit Report")
In Excel for Windows, the following example displays the contents of cell D5 as the jump text in the cell and opens the file named 1stqtr.xls, which is stored on the server named FINANCE in the Statements share. This example uses a UNC path:
=HYPERLINK("\\FINANCE\Statements\1stqtr.xls", D5)
The following example opens the file 1stqtr.xls in Excel for Windows that is stored in a directory named Finance on drive D, and displays the numeric value stored in cell H10:
=HYPERLINK("D:\FINANCE\1stqtr.xls", H10)
In Excel for Windows, the following example creates a hyperlink to the area named Totals in another (external) workbook, Mybook.xls:
=HYPERLINK("[C:\My Documents\Mybook.xls]Totals")
In Microsoft Excel for the Macintosh, the following example displays "Click here" in the cell and opens the file named First Quarter that is stored in a folder named Budget Reports on the hard drive named Macintosh HD:
=HYPERLINK("Macintosh HD:Budget Reports:First Quarter", "Click here")
You can create hyperlinks within a worksheet to jump from one cell to another cell. For example, if the active worksheet is the sheet named June in the workbook named Budget, the following formula creates a hyperlink to cell E56. The link text itself is the value in cell E56.
=HYPERLINK("[Budget]June!E56", E56)
To jump to a different sheet in the same workbook, change the name of the sheet in the link. In the previous example, to create a link to cell E56 on the September sheet, change the word "June" to "September."

Create a hyperlink to an e-mail address
When you click a hyperlink to an e-mail address, your e-mail program automatically starts and creates an e-mail message with the correct address in the To box, provided that you have an e-mail program installed.
1.       On a worksheet, click the cell where you want to create a hyperlink.
 Tip   You can also select an object, such as a picture or an element in a chart, that you want to use to represent the hyperlink.
On the Insert tab, in the Links group, click Hyperlink.
 Tip    You can also right-click the cell or object and then click Hyperlink on the shortcut menu, or you can press CTRL+K.
2.       Under Link to, click E-mail Address.
3.       In the E-mail address box, type the e-mail address that you want.
4.       In the Subject box, type the subject of the e-mail message.

5.       In the Text to display box, type the text that you want to use to represent the hyperlink.
6.       To display helpful information when you rest the pointer on the hyperlink, click ScreenTip, type the text that you want in the ScreenTip text box, and then click OK.
 Tip   You can also create a hyperlink to an e-mail address in a cell by typing the address directly in the cell. For example, a hyperlink is created automatically when you type an e-mail address, such as someone@example.com.
Create an external reference link to worksheet data on the Web
1.       Open the source workbook and select the cell or cell range that you want to copy.
2.       On the Home tab, in the Clipboard group, click Copy.
3.       Switch to the worksheet that you want to place the information in, and then click the cell where you want the information to appear.
4.       On the Home tab, in the Clipboard group, click Paste Special.
5.       Click Paste Link.
Excel creates an external reference link for the cell or each cell in the cell range.
 Note   You may find it more convenient to create an external reference link without opening the workbook on the Web. For each cell in the destination workbook where you want the external reference link, click the cell, and then type an equal sign (=), the URL (Uniform Resource Locator (URL): An address that specifies a protocol (such as HTTP or FTP) and a location of an object, document, World Wide Web page, or other destination on the Internet or an intranet, for example: http://www.microsoft.com/.) address, and the location in the workbook. For example:
='http://www.someones.homepage/[file.xls]Sheet1'!A1
='ftp.server.somewhere/file.xls'!MyNamedCell

Select a hyperlink without activating the link
·         Click the cell that contains the hyperlink, hold the mouse button until the pointer becomes a cross , and then release the mouse button.
·         Use the arrow keys to select the cell that contains the hyperlink.
·         If the hyperlink is represented by a graphic, hold down CTRL, and then click the graphic.


Change a hyperlink
You can change an existing hyperlink in your workbook by changing its destination (destination: General term for the name of the element you go to from a hyperlink.), its appearance, or the text or graphic that is used to represent it.
Change the destination of a hyperlink
1.       Select the cell or graphic that contains the hyperlink that you want to change.
 Tip   To select a cell that contains a hyperlink without going to the hyperlink destination, click the cell and hold the mouse button until the pointer becomes a cross , and then release the mouse button. You can also use the arrow keys to select the cell. To select a graphic, hold down CTRL and click the graphic.
On the Insert tab, in the Links group, click Hyperlink.
 Tip    You can also right-click the cell or graphic and then click Edit Hyperlink on the shortcut menu, or you can press CTRL+K.


2.       In the Edit Hyperlink dialog box, make the changes that you want.
 Note   If the hyperlink was created by using the HYPERLINK worksheet function, you must edit the formula to change the destination. Select the cell that contains the hyperlink, and then click the formula bar (formula bar: A bar at the top of the Excel window that you use to enter or edit values or formulas in cells or charts. Displays the constant value or formula stored in the active cell.) to edit the formula.
Change the appearance of hyperlink text
You can change the appearance of all hyperlink text in the current workbook by changing the cell style for hyperlinks.
On the Home tab, in the Styles group, click Cell Styles.
1.       Under Data and Model, do the following:
·         To change the appearance of hyperlinks that have not been clicked to go to their destinations, right-click Hyperlink, and then click Modify.
·          
·         To change the appearance of hyperlinks that have been clicked to go to their destinations, right-click Followed Hyperlink, and then click Modify.

Note   The Hyperlink cell style is available only when the workbook contains a hyperlink. The Followed Hyperlink cell style is available only when the workbook contains a hyperlink that has been clicked.
2.       In the Style dialog box, click Format.
3.       On the Font tab and Fill tab, select the formatting options that you want, and then click OK.
 Notes 
·         The options that you select in the Format Cells dialog box appear as selected under Style includes in the Style dialog box. You can clear the check boxes for any options that you don't want to apply.
·         Changes that you make to the Hyperlink and Followed Hyperlink cell styles apply to all hyperlinks in the current workbook. You cannot change the appearance of individual hyperlinks.
Change the text or graphic for a hyperlink
1.       Select the cell or graphic that contains the hyperlink that you want to change.
 Tip   To select a cell that contains a hyperlink without going to the hyperlink destination, click the cell and hold the mouse button until the pointer becomes a cross , and then release the mouse button. You can also use the arrow keys to select the cell. To select a graphic, hold down CTRL and click the graphic.
2.       Do one or more of the following:
·         To change the format of a graphic, right-click it, and then click the option that you need to change its format.
·         To change text in a graphic, double-click the selected graphic, and then make the changes that you want.
·         To change the graphic that represents the hyperlink, insert a new graphic, make it a hyperlink with the same destination, and then delete the old graphic and hyperlink.

Copy or move a hyperlink
2.       Right-click the cell that you want to copy or move the hyperlink to, and then click Paste on the shortcut menu.

Set the base address for the hyperlinks in a workbook
By default, unspecified paths to hyperlink (hyperlink: A word, phrase, picture, icon, symbol or other element in a computer document or webpage on which a user may click to move to another part of the document or webpage or to open another document, webpage, or file.) destination files are relative to the location of the active workbook. Use this procedure when you want to set a different default path. Each time that you create a hyperlink to a file in that location, you only have to specify the file name, not the path, in the Insert Hyperlink dialog box.
1.       Click the Microsoft Office Button , click Prepare, and then click Properties.
2.       In the Document Information Panel, click Document Properties, and then click Advanced Properties.
3.       Click the Summary tab.
4.       In the Hyperlink base box, type the path that you want to use.
 Note   You can override the hyperlink base address by using the full, or absolute, address for the hyperlink in the Insert Hyperlink dialog box.

Delete a hyperlink
To delete a hyperlink, do one of the following:
·         To delete a hyperlink and the text that represents it, right-click the cell that contains the hyperlink, and then click Clear Contents on the shortcut menu.
·         To delete a hyperlink and the graphic that represents it, hold down CTRL and click the graphic, and then press DELETE.
·         To turn off a single hyperlink, right-click the hyperlink, and then click Remove Hyperlink on the shortcut menu.
·         To turn off several hyperlinks at once, do the following:
1.       In a blank cell, type the number 1.
2.       Right-click the cell, and then click Copy on the shortcut menu.
3.       Hold down CTRL and select each hyperlink that you want to turn off.
 Tip   To select a cell that has a hyperlink in it without going to the hyperlink destination, click the cell and hold the mouse button until the pointer becomes a cross , and then release the mouse button.
4.       On the Home tab, in the Clipboard group, click the arrow below Paste, and then click Paste Special.
5.       Under Operation, click Multiply, and then click OK.
6.       On the Home tab, in the Styles group, click Cell Styles.
7.       Under Good, Bad, and Neutral, select Normal.
Note: I copied this from MS Office package.