DataSource Controls :: Display Varchar Values In Descending Order Like MM-YY Format
Jan 25, 2010
I have a column of type varchar that lists the values in this format:
SEP-09
SEP-08
OCT-09
OCT-08
NOV-09
NOV-08
MAY-09
MAR-09
JUN-09
JUL-09
JAN-10
JAN-09
I need to sort this list by descending order treated as actual date. I tried converting it to date and then tried to extract the year and month out but I keep receiving conversion errors. Does anyone know how to get this in the descending order to it shows up like this:
JAN-10
NOV-09
OCT-09
SEP-09
JUL-09
NOV-08
OCT-08
SEP-08
JUN-09
MAY-09
MAR-09
JAN-09
This is the closest I got but it keeps sorting the list alphabetically:
select distinct periodname, Convert(varchar,periodname,112) from periodtableorder by Convert(varchar,periodname,112) desc
View 2 Replies
Similar Messages:
Jan 12, 2010
I have a stored proc which returns months year in nice words, but having problem ordering them:
SELECT count(id) as counter, datename(MONTH, PublishDate) + ' ' + datename(YEAR, PublishDate) as date
from BLG_BlogPost where active=1 group by datename(MONTH, PublishDate) + ' ' + datename(YEAR, PublishDate)
And that returns:
April 2009 (8)
August 2009 (3)
February 2009 (2)
How can i order them?
View 3 Replies
Mar 20, 2010
I am a bit confused how to say this but here goes.I have a sql server 2008 database tablewhere I want to select rows by descending order of a [column name] and then select first 10 rows from that output.I was trying something like select top 5 * from (select * from movie_data order by hits DESC);this does not work and I'm quite new to query-writing.
View 2 Replies
Apr 16, 2010
How to sort the dataset Values in Descending order , I have Followed the following way
decimal Length = 94;
decimal Width = 7;
decimal Height = 13;
DataTable dtCarton = new DataTable();
[Code]....
View 6 Replies
Dec 13, 2010
I need to retrieve and display directory files in descending order. For example:
file-02_01_2010.txt should display before file-01_01_2010.
I am using DirectoryInfo.getfile(searchPattern) but that will return files in random order (or maybe ascending order, I am not sure). Is there a way to specify the order in which I need files to be returned? I know I can load them into an array, sort them, etc., etc., but is there any cleaner way?
View 7 Replies
Apr 21, 2010
In my database im storeing date as varchar. Now i want to display the table in grid view sorted by date.So how to convert varchar to datetime.
Im trying the following querry but its not working.
SELECT
[Name],
convert(datetime
,103,[sdate]),
[place], [country],
FROM [table]
View 10 Replies
Apr 28, 2013
I have a datatable,columns are(User_id,Name,Address,DOB)
values like(12,abc,delhi,22/2/2000)
(14,pqr,mumbai,13/3/1989)
(8,klm,banglore,17/5/2001)
(9,asd,pune,12/9/1999)
Now I want to sort these rows on DOB in descending order..how can i do so?
View 1 Replies
Apr 15, 2010
I want to write a LINQ to Entity query which does order by ascending or descending based on input parameter, Is there any way for that. Following is the my code.
public List<Hosters_HostingProviderDetail> GetPendingApproval(SortOrder sortOrder)
{
List<Hosters_HostingProviderDetail> returnList = new List<Hosters_HostingProviderDetail>();
int pendingStateId = Convert.ToInt32(State.Pending);
//If the sort order is ascending
if (sortOrder == SortOrder.ASC)
{
var hosters = from e in context.Hosters_HostingProviderDetail
where e.ActiveStatusID == pendingStateId
orderby e.HostingProviderName ascending
select e;
returnList = hosters.ToList<Hosters_HostingProviderDetail>();
return returnList;
}
else
{
var hosters = from e in context.Hosters_HostingProviderDetail
where e.StateID == pendingStateId
orderby e.HostingProviderName descending
select e;
returnList = hosters.ToList<Hosters_HostingProviderDetail>();
return returnList;
}
}
View 2 Replies
Aug 14, 2010
i m using asp.net 2005 with access 2003. i need a code using vb.
how can i sort the record in descending order?
View 3 Replies
Apr 15, 2010
Order by descending is not working on LINQ to Entity In the following Query In place of ascending If I keep descending it is not working.
[code]....
View 1 Replies
Oct 16, 2012
I am using dropdownlist to select whether the gridview should be filled by data arranged in ascending order or descending order with Gridview Paging. The problem i am encountering is that when i fill the data in ascending order it works fine but when i arrange the data in descending order the first page loads fine but the other pages are not filled properly in paging.
View 1 Replies
Oct 12, 2010
In my table I have a varchar type column, the values like..
sale_date
04/23/2010
02/03/2010
12/24/2010
I need to retrieve the records in both ascending and descending order. Problem is now it is a varchar type if I use order by o/p like
02/03/2010
04/23/2010
12/24/2010
I tried with convert(DATETIME,sale_date) but no use.
View 4 Replies
Jan 20, 2010
Am using the addrotator in an update panel to display people images.
The data source is MS SQL server.
On my data access layer I have queried the information Ordered alphabetically using Names.
However the add rotator displays them randomly.
View 7 Replies
Feb 12, 2010
Im developing a web application in asp.net where i have gridview with some text box controls in it.In runtime we are creating a new row dynamically by clicking add button .To insert data into the database.i used a stringbuilder instead of string becoz the data what i have to insert into database is more.but i am gettin the following error No mapping exists from object type System.Text.StringBuilder to a known managed provider native type. in database the datafield column datatype is varchar(max).
View 3 Replies
Mar 2, 2010
I want to use three language: English, German and italian. If i will use varchar type, will i face any problem or I have to use nVarchar.
View 3 Replies
Sep 29, 2010
I have a little problem developing a SQL Select Statement on a column that is formatted pretty badly. Firstly, the Database has already been created and filled with Data in a Test Environment, I'm not sure if the format is the same or has been updated in Production but since I'm only able to work with the Test Environment right now I'm stuck with using what I have. The Column in one Table shows a Snapshot of a clients account which is set to VarChar(50) but the actual data in the column is formatted like a money format (with a $ and decimal point so for example "$5,000.00" would be an entry in one Row).
What I'm trying to do is a create a WebService that will be used in a iPhone Application and one of the Methods needs to just give a quick display of the total value of all Clients with each specific company but I can't perform a SUM function on a VarChar column and I've tried to CAST and CONVERT the column into money, int, decimal and just about every format I can think of but I keep getting an error stating that I convert the data type varchar to which ever one I'm trying. I think it has something to do with the $ already listed in the Column, so I wanted to know what I could do to either remove the $ sign (like a Trim option) or if there is a better way of doing this that I can't think of. I know the best option would be to convert the column to the appropriate format but as I said, this was a previously designed system and I'm not sure if the Production area is the same (most likely not).
Here's what I've tried so far:
[Code]....
View 5 Replies
Apr 4, 2010
What are the basic difference between the char and varchar datatype ?
View 5 Replies
Apr 1, 2010
i want to convert all my database columns whose data type is char,varchar, nchar to nvarchar datatype. But the main problem is that some of my primary key, foreign key columns are also of varchar datatype. So when i try to change their datatypes to nvarchar then i receive the errors related to constraints of Primary Key, Unique Key and indexes. how to change the datatypes to nvarchar after droping the constraints and after changing all constraints will apply again. I also want that no data loss will occur.
View 5 Replies
May 7, 2010
I am using:
href='<%# Eval("Directory")+eval("Agenda")%>
to provide a link to documents held in directory so directory contains [URL] or [URL] Agenda contains
00209-FebruaryMtgMin%5E_.pdf
If I declare Directory as VarChar(nnn) where nnn is large enough to accomodate the longer field, The statement <%# Eval("Directory")+eval("Agenda")%> returns
[URL]self.aspx/.Public/ 00209-FebruaryMtgMin%5E_.pdf
How can I get rid of the Pad characters?
View 3 Replies
Aug 24, 2010
I want to retrieve the full SQL that my Web Application generates and executes on the database. So when the INSERTED or UPDATED events are triggered on the SqlDataSource, I want to get that particular SQL Statement.
The problem I've got there though is when I use "e.Command.CommandText" that gets the SQL statement with the paramter names NOT the paramter values. I specifically need the values.
So... how can I get it to display the full SQL statement containing submitted values!?
View 6 Replies
Mar 4, 2010
I have an output parameter called '@packIds', that I create in ADO.Net using the code below:
SqlParameter packIdPara = new SqlParameter("@packIds", null);
packIdPara.SqlDbType = SqlDbType.VarChar;
packIdPara.Direction = ParameterDirection.Output;
sqlCmd.Parameters.Add(packIdPara);
How will I specify that the parameter '@packIds' is of max size? I cannot find any code for this.
[Code]....
View 3 Replies
Mar 9, 2010
I save dates as a string in a varchar data field named "TilDato" in a SQLServer-express table. I want to filter the records smaller than a specific date from a variable in the script. I try the following statement, but it does not seems function logically.
objCmd = new
SqlCommand("SELECT * FROM Reservering WHERE @laanedato<=TilDato",myConn2);
objCmd.Parameters.Add("@laanedato", laanedato);
objRdr = objCmd.ExecuteReader();
View 2 Replies
Aug 12, 2010
My database includes a table with sever filds which are defined as (varchar(1),null), I tried using DBNull.Value, null, ' ' but cannot get a null inserted in that field of the database,
[Code]....
View 4 Replies
Apr 13, 2010
when I edit varchar field and save it to Sql Server, edited non-english text look as ??? symbols.I tried to correct this as
in web.config:
<globalization
fileEncoding="windows-1251"
[code]...
View 3 Replies
Jul 4, 2010
I get the following error: The data types text and varchar are incompatible in the equal to operator.here's my code (PageName is a string Parameter) :
SqlConnection sql = SQLconnection();
en();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Select title, text, postdate, sticky from articles where pagename = @pagename;";
[code]...
View 2 Replies