473,700 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

smalldatetime and sorting

Hello all and thank you for your time.

I have a datagrid where I want to view dates (smalldatetime) and be
able to sort on the field. However, I do not want to have the time
part show. If I use the convert function(conver t(char,ProjDate ,101) as
ProjDate) the field is then a char and does not sort correctly.

Any solutions?

Thanks again,
Sunshine

Jul 23 '05 #1
3 3177

<su************ @yahoo.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hello all and thank you for your time.

I have a datagrid where I want to view dates (smalldatetime) and be
able to sort on the field. However, I do not want to have the time
part show. If I use the convert function(conver t(char,ProjDate ,101) as
ProjDate) the field is then a char and does not sort correctly.

Any solutions?

Thanks again,
Sunshine


I don't know much about datagrids, but you might find it easier to do this
in the datagrid, not the server. To get dates to sort correctly using
CONVERT(), you would have to do something like this (there may be other
formats which work too):

convert(char(8) , ProjDate, 112)

That will always sort correctly, but it may not be in the format your users
want or expect, especially if you need to support international locations
with different locales. In general, any sort of formatting and presentation
is best done in the front end, and that's especially true of things that
depend on a user's locale, so I would investigate what you can do in the
datagrid itself.

Simon
Jul 23 '05 #2
I ended up just pulling the data as a smalldatetime anyway. In the
datagrid column, I used {0:MM/dd/yyyy} to format the date and it works
fine.

Sunshine

Jul 23 '05 #3
(su************ @yahoo.com) writes:
I ended up just pulling the data as a smalldatetime anyway. In the
datagrid column, I used {0:MM/dd/yyyy} to format the date and it works
fine.


I don't know the datagrid, but you should really just set up the date
format according to the regional settings in Windows, and not hard-code a
format. (And if you hard-code a format, you should use YYYY-MM-DD and
not one that is likely to misunderstood in most countries in the world.)
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5568
by: Joey Martin | last post by:
How do I convert an nvarchar field to smalldatetime format? My nvarcharfield (saledatetext) is in the format YYYY-MM-DD. I want to convert is to smalldatetime (field: saledate) Thanks for the help *** Sent via Developersdex http://www.developersdex.com ***
2
2222
by: Joey Martin | last post by:
Please help. I have a ms sql table called data. Two fields, saledate(smalldatetime),saledatetext(nvarchar) I have dates (ex. 05/04/05) in the saledatetext, but I need this converted into smalldatetime format and placed in the saledate column. Can you tell me how to do this using sql query analyzer?
7
32963
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r = sd.Date; r = rangeTide; etc.
7
4684
by: Bostonasian | last post by:
I have a table that contains transactional data. Such as site view by whom, when, which template, etc, etc... Everytime when I pulled the report, hh:mm:ss never matters. Only breakdown by dates, not time. Having read some chapters of Ralph Kimball's book, I am inspired to build "date" table with integer as primary key. Here's what I have for schema of transactional table. - viewed_customer_id int (4bytes)
2
6938
by: Marc Pelletier | last post by:
Hello all, I have a library of datetime routines that make things simpler for me. Before I discovered DateTime.MinValue I had a function that looked like public static DateTime DayZero { get { return new DateTime( 0,0,0); } } I use it to compare for nonvalid datimes in some code, for example if moonrise equals DayZero then the moon doesn't rise on that day.
2
5933
by: Salim Afþar | last post by:
Hi, How can I cast from datetime type to smalldatetime type. I get the records from a table which has got a datetime type column but I want to display it smalldatetime format. Thanks, Salim
2
2668
by: .Net Sports | last post by:
I'm using these to assign a variable to a smalldatetime object in sql server: dim todnews = DateTime.Today.ToString ( "d" ) 'connection string to server is on this line Dim strSQL2 as string ="SELECT Arrived,Title,ID,story FROM tblGeneral WHERE Arrived = 'todnews'" ...but I get a syntax error saying i can't change a string to smalldatetime data type. When I try replacing DateTime.Today.ToString (
5
2681
by: Dimitri Furman | last post by:
This looks like a bug - hopefully somebody can explain what is actually happening. Using SQL Server 2000 SP4. Here's a repro script with comments: /* repro table */ CREATE TABLE dbo.T ( ID int NOT NULL, Time datetime NOT NULL, CONSTRAINT PK_T PRIMARY KEY (ID, Time)
6
7652
by: SQL Server | last post by:
I've been working this for a while. Kind of new to SQL Server functions and not seeing what I am doing wrong. I have this function CREATE FUNCTION dbo.test (@Group varchar(50)) RETURNS smalldatetime AS BEGIN Declare @retVal varchar(10) (SELECT @retVal= MIN() FROM dbo.t_master_schedules WHERE (event_id = 13) AND (group_ =@Group)) return convert(smalldatetime, @retVal, 1)
0
8649
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7819
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4408
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3097
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2032
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.