Convert() function

Hi, I have found some ways on using Convert() function for SQL server. But i do not understand some of them.

Example:

CONVERT(VARCHAR(10),column name,108)

What is the 108 for? I see some with 120 and 101. I tried all but only 108 is working for me the way I want..but i do not understand what is that for actually. Can anyone explain it to me? Thank you.

0
sophistLady
5/20/2005 5:15:08 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

2 Replies
325 Views

Similar Articles

[PageSpeed] 35

Hi,

You can get the time part of a date column value as varchar by using the convert function with style 108

Say,

select top 1 ApplicationDate from Applications

returns "2003-04-11 15:20:00"

Then

SELECT top 1 CONVERT(VARCHAR(10), ApplicationDate ,108) from Applications

will return

15:20:00

 

For more information check BOL for CAST and CONVERT

Eralper

http://www.kodyaz.com


 


http://www.eralper.com
http://www.kodyaz.com
0
eralper
5/20/2005 8:08:41 AM
Also, check out the Cast and Convert
topic on Books Online.  That third parameter to the CONVERT
function is the style and there are charts on that page which explain
the different possible style values.

The style I use most often is 112, which converts a datetime to an ISO date in the format YYYYMMDD.

Terri Morton
Engagement Manager, Neudesic

How to ask a question

0
tmorton
5/20/2005 9:59:54 PM
Reply:

Similar Artilces:

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

SQL Convert function
I am trying to concatenate a string to a currency amount so that I can show both in a drop down list box.  However when I create the SQL to do this using the Query tool I get a message to say that I must use the Convert funtion to convert the currency amount.Anyone know the SQL syntax for this function as I can seem to get it to work. ThanksPaul How does the string which you tried to use as currency look like? In SQL there is a MONEY datatype, which accepcts values like $999:DECLARE @m moneySET @m=$234325SELECT @mWelcome to my SQL/ASPNET forum for Chinese http://51up.org/bbs...

Help convert MS Access function to MS SQL User Defined Function
I have this function in access I need to be able to use in ms sql.  Having problems trying to get it to work.  The function gets rid of the leading zeros if the field being past dosn't have any non number characters.For example:TrimZero("000000001023") > "1023"TrimZero("E1025") > "E1025"TrimZero("000000021021") > "21021"TrimZero("R5545") > "R5545"Here is the function that works in access:Public Function TrimZero(strField As Variant) As String   Dim strReturn As String   If IsNull(strField) = True Then      strReturn = "" ...

SQL Convert Function #2
 Hi,Im trying to convert an integer to a varchar in a stored procedure on line 6. But for some reason I keep getting the same error msg when I try to load the page.Syntax error converting the varchar value '78 AV SE' to a column of data type int.  SELECT OrderNo,ServiceTypes.ServiceCode AS 'Svc: ',--AccountNumber,PickupCompanyName AS 'P: ',Convert(Varchar(10),PickupStreetNo) + ' ' + PickupStreet + '  '+ CASE When PickupUnit is Null Then ISNULL(PickupUnit, '') Else ' Unit '+ PickupUnit END AS 'P Address: ',--P...

Access SQL functions through .net??
I usually access stored procedures using SQL data source. But now  I need a string returned from the database. If I write a function in SQL how do I access it from an aspx.vb file? Put it in a proc and run an EXEC query, same way as any other procedure.JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. If the SQL function returns a string, why not use SqlCommand.ExecuteScalar method: using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionString...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

SQL function Convert INT to DATETIME
I have SQL table with dateTime field which is INT type (This field contains a number representing DATE / TIME) I would like to convert this umber to actuall date time output. However, SQL gives invalid date times. See below)  Appears the resulting date time are all the same.                     SQL COMMAND                                ...

Is there any function to convert string to integer in VB.net?
Is there any function to convert string to integer in VB.net? thank you very much.As Heinlein said "specialization is for insects" explore beyond the universe. Hi There, You can do this Dim Val as String = "50" Dim i As Integer = Convert.ToInt32(Val)DC517Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved. thank you very much dennisAs Heinlein said "specialization is for insects" explore beyond the universe. Hi There, No problem, always welcome...

convert ado.net datatype to sql datatype
I have included the code that converts ado.net datatype to sql datatype. The columns belong to the dataset. However I want to know if there is a more direct method of dealing with this instead of multiple if then else or switch case statements.  If column.DataType.ToString = "System.Double" ThencolumnType.Add("bigint") ElseIf column.DataType.ToString = "System.String" ThencolumnType.Add("ntext") ElseIf column.DataType.ToString = "System.DateTime" ThencolumnType.Add("datetime") Else : columnType.Add(column.Dat...

help, need this code converted to .net functions
I have the following code. I know that there is probably a completing different way of handling this in asp.net. What i need is this code converted to asp.net <% '****************************** ' Crypt.asp '****************************** Dim g_Key Const g_CryptThis = "12345678912345" Const g_KeyLocation = "" g_Key = "somekey" Response.Write "<p>ORIGINAL STRING: " & g_CryptThis & "<p>" Response.Write "<p>KEY VALUE: " & g_Key & "<p>" Response...

Converting from PHP/MySQL to .NET/SQL Server
Hello W are looking to convert several applications to .NET using SQL Server. I see where the migration assistant can be of great help with most of the code. I was wondering what would be the best approach to covert the SQL database syntax from MYSQL to SQL Server Thanks in advance for your help! Dave It depends on how you would like to do it. There are a few ways to go about it: A) Convert all applicable SQL to stored procedures. B) Convert most, but not all (some might be difficult) to stored procedures and leave the rest as they are. C) Leave them all. If you p...

converting sql to MS SQL
I'm trying to unload a SQL Anywhere database to a MS SQL 6.5 database. The SQL produced from SQL Anywhere is not at all compatible. Is there an easy way of moving a database from SQLA to MS SQL darrell@texas.net Look at PowerDesigner from Powersoft. I can reverse engineer SQLA and create the MSSQL Server DDL for you. Dave Wolf Sybase Professional Services Darrell Fuller wrote: > I'm trying to unload a SQL Anywhere database to a MS SQL 6.5 database. > The > SQL produced from SQL Anywhere is not at all compatible. Is there an easy > way of moving...

Is there a function in VB.Net to convert Hexidecimal to Decimal?
Hi, is there a function in VB.Net to convert Hex to Dec?Please help me. Thank You. =D Hi, Val("&hFF") or CInt("&hFF") or even better Convert.ToString("ff", 16) Notice the last option does not have the '&h' prefix. Hope this helpsChris Taylor My Blog...

converting string functions from vb.net to C#
Hi, I have a class written in vb.net and I am trying to convert it in C#. The function in the class makes use of string functions such Mid,Left, Instr. Private Function ManageUploadDirectory(ByVal strHTML As String, ByVal strUploadDirectory As String) As String Dim P As Integer P = InStr(1, strHTML.ToLower, "src=""") While P <> 0 ManageUploadDirectory = ManageUploadDirectory & Left(strHTML, P + 4) strHTML = Mid(strHTML, P + 5) ' add uploaddirectory if we ...

Not able to use sql Convert function in gridview
 Hi!Im trying to get europe time in one of my gridviews (instead of am/pm format), and tryed using following select-string:SelectCommand="SELECT Convert(DateTime, vagt.start, 13), vagt.***, medarbejder.fornavn + ' ' + medarbejder.efternavn AS Expr1, medarbejder.medarbejder_id, vagt.vagt_id FROM vagt INNER JOIN medarbejder ON vagt.medarbejder_id = medarbejder.medarbejder_id WHERE vagt.dags_id = @intDagsid" The thing to note ofc, is the Convert() part. Now, when i use that method on the "vagt.start" column, it gives me an error stating it cant fint a field...

Web resources about - Convert() function - asp.net.sql-datasource

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

TV binging, exercise skipping linked to poor cognitive function
... their fit, less TV-addicted counterparts. In particular, couch potatoes had slightly lower brain processing speeds and worse executive function, ...

iPhone best tricks and functions - Business Insider
Your iPhone can do a lot more than you think.

Review: HP Spectre 360 A Perfect Mix Of Style, Form, Function
HP Inc. delivers a brushed-aluminum laptop with a new 6th Generation Intel i7 processor, making it one of the best-looking, best-priced and best-performing ...

HPE Offers Catalog of Virtual Network Functions for Telcos
The vendor's OpenNFV Solution Portal gives carriers a single place to find a range of VNFs that are pre-tested to run on their networks.

Why Global Corporations Need To Redesign Their Strategic Planning Function
Corporate strategy teams play an important role in guiding business leaders to make smarter, better and more informed decisions, especially in ...

Sponsored post: Garmin’s fenix 3 Pairs Form and Function with GPS Watch
... timepiece to polish off a professional look, or strap on a rugged stopwatch for our workouts. But when it comes to everyday use, the functional ...

Code Craft – Embedding C++: Timing Virtual Functions
... compiler just like the standard language types. A subtype inherits the characteristics of its parent type and can use, or not, the member functions ...

Madras HC asks police to allow Tipu’s birth anniversary function
... Station on a petition filed by Ismail, General Secretary of Thamizhaga Makkal Jananayaga Katchi, seeking grant of permission to hold the function. ...

Colorado governor: This Planned Parenthood shooting may be a function of inflammatory rhetoric from bloggers ...
Via Grabien , skip to 4:45 of the clip below for the key bit. I naively thought we were (mostly) done with “climate of hate” stupidity after ...

Resources last updated: 12/11/2015 7:46:56 PM