473,513 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to trim off the time part of a DateTime field

ad
I have a tabls of SQL 2000, about the data of student.
The data is migrate from another databse,
There is a field called birthday, it stores the data with the formate like:
1994/11/03 AM 02:09:00

When I bind the field to datagrid, how can I suppress the time part , or
how can I trim the time part form database?
Nov 19 '05 #1
5 2644
you can use the CONVERT function in sql

try this:

CONVERT(varchar(20), Getdate(), 103)

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a tabls of SQL 2000, about the data of student.
The data is migrate from another databse,
There is a field called birthday, it stores the data with the formate
like:
1994/11/03 AM 02:09:00

When I bind the field to datagrid, how can I suppress the time part , or
how can I trim the time part form database?

Nov 19 '05 #2
Hi Kent,

You can make use form Data Format string property of the grid columns to
format the date.

For more input Refer http://www.dotnetspider.com/technology/kbpages/384.aspx.

With regards,

Sadha Sivam S,
Microsoft Community Star,
Sr. Engineer,
Aspire Systems,
www.dotnetspider.com

"ad" wrote:
I have a tabls of SQL 2000, about the data of student.
The data is migrate from another databse,
There is a field called birthday, it stores the data with the formate like:
1994/11/03 AM 02:09:00

When I bind the field to datagrid, how can I suppress the time part , or
how can I trim the time part form database?

Nov 19 '05 #3
If it is only for display purpose you can use this
Datime objDt = new datetime.now
objDt.ToString("MMM dd yyyy");

For any other purpose, you don't really need to do conversion.
[See DateTime.ToString in MSDN]

Ural

"mavisahdas" wrote:
Hi Kent,

You can make use form Data Format string property of the grid columns to
format the date.

For more input Refer http://www.dotnetspider.com/technology/kbpages/384.aspx.

With regards,

Sadha Sivam S,
Microsoft Community Star,
Sr. Engineer,
Aspire Systems,
www.dotnetspider.com

"ad" wrote:
I have a tabls of SQL 2000, about the data of student.
The data is migrate from another databse,
There is a field called birthday, it stores the data with the formate like:
1994/11/03 AM 02:09:00

When I bind the field to datagrid, how can I suppress the time part , or
how can I trim the time part form database?

Nov 19 '05 #4
ad
Thank,
But I don't just for desplay purpose.
I want to really trim off the time part of that field in database.

Could somebody tell me how to do?
"ural" <ur**@discussions.microsoft.com> ¼¶¼g©ó¶l¥ó·s»D
:46**********************************@microsoft.co m...
If it is only for display purpose you can use this
Datime objDt = new datetime.now
objDt.ToString("MMM dd yyyy");

For any other purpose, you don't really need to do conversion.
[See DateTime.ToString in MSDN]

Ural

"mavisahdas" wrote:
Hi Kent,

You can make use form Data Format string property of the grid columns to
format the date.

For more input Refer http://www.dotnetspider.com/technology/kbpages/384.aspx.
With regards,

Sadha Sivam S,
Microsoft Community Star,
Sr. Engineer,
Aspire Systems,
www.dotnetspider.com

"ad" wrote:
I have a tabls of SQL 2000, about the data of student.
The data is migrate from another databse,
There is a field called birthday, it stores the data with the formate like: 1994/11/03 AM 02:09:00

When I bind the field to datagrid, how can I suppress the time part , or how can I trim the time part form database?

Nov 19 '05 #5

Hi ad:

You can use CONVERT, as suggested ealier. The datetime datatype in SQL
will always store a time, however, even if the time is always 12:00
AM. SQL 2005 as far as I know dropped support for unique date and time
datatypes. The only other real choice is to just store a date as
varchar or nvarchar.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 4 May 2005 20:00:57 +0800, "ad" <ad@wfes.tcc.edu.tw> wrote:
Thank,
But I don't just for desplay purpose.
I want to really trim off the time part of that field in database.

Could somebody tell me how to do?
"ural" <ur**@discussions.microsoft.com> ¼¶¼g©ó¶l¥ó·s»D
:46**********************************@microsoft.c om...
If it is only for display purpose you can use this
Datime objDt = new datetime.now
objDt.ToString("MMM dd yyyy");

For any other purpose, you don't really need to do conversion.
[See DateTime.ToString in MSDN]

Ural

"mavisahdas" wrote:
> Hi Kent,
>
> You can make use form Data Format string property of the grid columns to
> format the date.
>
> For more input Referhttp://www.dotnetspider.com/technology/kbpages/384.aspx. >
> With regards,
>
> Sadha Sivam S,
> Microsoft Community Star,
> Sr. Engineer,
> Aspire Systems,
> www.dotnetspider.com
>
>
>
> "ad" wrote:
>
> > I have a tabls of SQL 2000, about the data of student.
> > The data is migrate from another databse,
> > There is a field called birthday, it stores the data with the formatelike: > > 1994/11/03 AM 02:09:00
> >
> > When I bind the field to datagrid, how can I suppress the time part ,or > > how can I trim the time part form database?
> >
> >
> >


Nov 19 '05 #6

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

Similar topics

1
17130
by: v0lcan0 | last post by:
Any help on extracting the time part from the datetime field in SQL database. even though i had entered only the time part in the database when i extract the field it gives me only the date part. i’m using Vb.net datagrid as a front end. any assistance appreciated!! :?: --
3
1675
by: wrytat | last post by:
I have a table in my database that has a DateTime field that stores a time that I want to compare with the current time in my asp.net vb codes. The value stored in the field is for example, 01/01/1900 11:00:00. So actually I'm only interested with 11:00 am. And let's say the time I want to compare with is 26/09/2005 08:06:05; then I would...
4
2457
by: John | last post by:
Hi I have a start date and a start time field. I also have a timespan value which can be anything from 5 minutes (TimeSpan(0, 5, 0)) to 2 weeks (TimeSpan(14, 0, 0, 0)). How can I get an end date and end time (separate fields) by adding timespan to start date & start time? Thanks Regards
15
18862
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract the value in timeonly format by using this command Format(now,"HH:mm:ss") But when I insert it into the Sql Server database, it embadded date value...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7397
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. ...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5703
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...
1
5102
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...
0
4757
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...
0
3252
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...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
470
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...

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.