getting just the date or from DateTime field


I have used smalldatetime datatype to store my date and time values. i want to store just the date or time but the problem is it stores both the date and time. For eg, if i add the the date 03/11/2004, it also the stores the current time automatically. so the new value will be something like 03/11/2004 10:00:00 AM where i want just 03/11/2004. further problem is even though i managed to store just the date like 03/11/2004 in the database, whole date and time shows up when i display it in my pages.
any help will be appreciated.
-keeara g
9/3/2004 3:45:06 AM 29906 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 38
Get it on Google Play
Get it on Apple App Store

If i want to display just the date portion I use the following.

This is just using a datareader then putting the date in a label

While drDate.Read()
lblSent.Text = Format(drDate("datesent_column"), "dd/MM/yyyy")
End While

If you are in the US you might use "MM/dd/yyyy" instead of our aussie way.
It doesn't matter then if the whole date and time is in the column.
Hope this helps
"Ever tried, ever failed? No matter, try again, fail better!"
9/3/2004 2:19:43 PM
You should just use the more generic "short date formats" rather than hard-coding the format, but the general idea is sound.
9/5/2004 1:01:56 AM
hi pkr,

even though i use short date formats, they will be in long date format when saved in database. i have used shortdatetime datatype in database as well.
seems like i need to format it again while displaying. is that the only solution?

-keeara g
9/5/2004 8:43:24 AM
SQL Server *only* supports date AND time. There's no getting around that fact, well not really anyway. My posting was talking about using the generic formats for rendering the values not storing them. You should always strive to use the users date formatting not impose one for them.
9/6/2004 7:40:16 AM

Similar Artilces:

Getting just the date from a "datetime" sql column along with other data of different formats
Hi. I have a web page that gets the current user, then goes into a database and gets a list of invoices, this includes: invoice numbers, the date of the invoice, the date the invoice was paid, and the amount of the invoice. The data is then bound to a repeater control and displayed. i need a way to get just the date and not the date and time from the datetime columns. Here is my code that i have now: This next part gets the current user, then creates the selection string and binds the repeater to the data.Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ...

get DateTime.Now.Date in sql
 Hi, Im making an c# website. I use an dataset and an gridview.  I will fill an gridview with users with the follow sql query:SELECT     UserIdFROM         StatsWHERE     LunchDate =  DateTime.Now.Date()How can I get all the users with the date of today?I have try the follow solution but it doesnt work:SELECT     UserId FROM         Stats WHERE     LunchDate =  @LunchDateIn the objectDataSource I hav...

Select all dates from SQL datetime field
I have a form that's filtering search results and porting to a gridview. The drop down is selecting from the date column of SQL, but i want it the default value to show all dates in the gridview. In a normal string field, you can just use "%", but a datetime field won't take this. What can i use to show all dates? Can you post the SQL you have currently and how the value from the ftont-end is passed to the DB?***********************Dinakar NethiLife is short. Enjoy it.*********************** <asp:SqlDataSource ID="LDSSqlDataSource1" runat="serve...

Getting just time from datetime fields
I have some datetime fields that I want to get just the time out of. I know I can get the date by using "date(fieldname)", but I haven't found an equivalent "time(fieldname)". Is there a way to do this? I am using Infomaker 10. Thanks On 14 Nov 2005 13:37:12 -0800, Tom Minich wrote: >I have some datetime fields that I want to get just the time >out of. I know I can get the date by using >"date(fieldname)", but I haven't found an equivalent >"time(fieldname)". Is there a way to do this? I am using >Infomaker 10. ...

SQL DateTime and Searching for just the date portion
I have a SQL DB with a column called time_occurred that is formatted like ( 7/28/2004 7:10:30 AM ). What I need to do is run a report based on just the month day and year portion. I am using the calendar control so mins, sec and milliseconds are not available nor do I really need them. I am running the Query with this Stored Procedure ALTER PROCEDURE dbo.Prodecure1 ( @WhereClause varchar(8000) ) AS -- Create a variable @SQLStatement DECLARE @SQLStatement varchar(8000) -- Enter the dynamic SQL statement into the variable @SQLStatemen...

getting JUST date from datetime not displaying correctly
here is my select command: SelectCommand="SELECT [JobID], [EmployeeName], CAST( STR(YEAR(DATEENTERED)) + '/' + STR(MONTH(DATEENTERED)) + '/' + STR(DAY(DATEENTERED)) AS DATETIME ) AS Date, [From], [To], [Company], [Catagory], [Client], [Description], [TotalHours] FROM [JcpowersJobs]" It will show correctly in the query builder test but when you load it up in the gridview it will show the date AND 12:00:00AM for every one of the dates I tried replacing DATETIME with VARCHAR but it would insert spaces into the date where I didn't want them:...

select statement to get date from datetime field... help
Hi All, Could someone please help how to compose select statement to get date only from date/time field in ms access? In sql server there is convert function but i have ms access here... Regards, Paul   You can use the Format function. See #8 in this post was useful to you, please mark it as answer. Thank you! That's a useful article Johan has linked to, but my preference is to get the whole value of the field out of Access, then use string formatting in ASP.NET to change the way it displays: http://www.m...

Problem getting focus in fields containing date and datetime
I've PB 5.0.4 on NT 4 with several applications which use different databases (Oracle, Informix and Access). My problem refers to only one of these (the Oracle one): when a field (in a datawindow or in a window) get focus, the editing size is reduced. The fact is that I have a lot of date field that crash becouse of the field size is measured. My colleagues does'n have the problem in spite of the sources are the same (but the OS is different, they have windows 95-98) Probably this is since I've installed PB 7 on my machine. Thanks Matteo Date fields under NT4 have...

A SQL-TRANSACT Question How to Return only the Date Part of a DateTime Field.
VWD 2008 Express. Visual Basic. I have a SQL table I am querying from my aspx code behind.  The table has a column that is a datetime datatype.  I want to only return the date portion of the column.  What can I use in my SQL SELECT statement to return only the date part?  By this I mean instead of mm/dd/yyyy hh:mm:ss I just want mm/dd/yy.  I have seen the CONVERT function, but it does not seem to do the job.  Thanks for any help.Dr. Douglas PruiettGood News Jail & Prison select convert(varchar, getdate(), 101) - WilliamPl...

get a date from two date field
how to use a stored procedure to get a date which is start_date + due_date. stare_date and due_date are data field. dats type are smalldatetime. database is SQL 2000.   Give an example of what you want..... Do you want something like 12/12/2005 12/25/2005 ? Eric RamseurRainbow Portal 2.0 AdminDownload Rainbow 2.0!!Rainbow Code Rainbow Portal CommunityC# 2005 Group I need a date, 60 days before start date +  due days. For example, start is 12/03/2005(smalldatetime) Due days is 20(int).   start date + due day - 60 is 10/23/2005. that's what I...

get only date from a date with a datetime format
i have a problem with dates when it comes to searchingbasically, SQL searches for a date including the seconds,but i only need to date so that in any given time, it will yield a's a part of my code-behind code: reqNo = RequisitionsLogic.GetReqNoByDate(currentDate, requestorCode)and here's the SQL statement created in a TableAdapter:SELECT RequisitionNoFROM RequisitionsWHERE (RequisitionDate = @RequisitionDate) AND (RequestorCode = @RequestorCode) take a look with this, don't just accept influenceshttp://thedailyarr.tk

Free .Net and Sql Server Training Videos for Developers just getting started
I figured since this is the Getting started forum I would mention a great .Net training video site with some free videos.http://www.TechnicalVideos.netThanksMike James...

Get date portion from DateTime (with DateTime property)
    private string _Date;    public string Date    {        get { return _Date; }        set { _Date = value; }    } objDados.Date = Convert.ToDateTime(drResult["APP_DATE"]).Date.ToString("dd/MM/yyyy"); If I replace _Date from string to DateTime, how can I get only date portion from DateTime? ThanksBest regards,Ivan Andrade Hi  you could always copy it. But I'd put the Date property to be of DateTime type. Something like:  &...

Converting Date field and Time field to DateTime
D2007 We are converting data for a new customer. The old data has a field for 'updt-dt' which is a Date field. The old data has a field for 'updt-tm' which is an Integer field. We need to combine to have a DateTimeStamp. var OldDate, OldTime : TDateTime; looping FieldNameFrom := 'updt-dt'; FieldNameFrom2 := 'updt-tm'; if (not FieldByName(FieldNameFrom).IsNull) and (not FieldByName(FieldNameFrom2).IsNull) then begin Day := 0; Month := 0; Year := 0; ...

Web resources about - getting just the date or from DateTime field -

Is there a JQuery plugin to convert UTC datetimes to local user timezone?
If I have a tag: &lt;span class="utctime"&gt;2010-01-01 11:30 PM&lt;/span&gt; I would like a jquery script or plug in to convert every utctime ...

Targetprocess 3.7.3: Epic unit for Bug/Story cards, new DateTime functions in Webhook plugin
Webhook plugin supports new DateTime functions AddDays(DateTime date, int days) – Returns a new date with the number of days added. The number ...

Common Pitfalls when working with DateTime’s
In .NET, the DateTime structure provides us wonderful functionality, but this seemingly simple structure can cause a lot of headaches if you ...

Parsing Twitter Date format to .Net DateTime
Recently when I needed to parse the twitter datetime format into a .Net DateTime I found this post on the web showing how to do it. However, ...

C Sharp (programming language) - Wikipedia, the free encyclopedia
(pronounced see sharp ) is a multi-paradigm programming language encompassing strong typing , imperative , declarative , functional , generic ...

1753 - Wikipedia, the free encyclopedia
Language: English Afrikaans አማርኛ العربية Aragonés Asturianu Aymar aru Azərbaycanca বাংলা Bân-lâm-gú Basa Banyumasan Беларуская ‪Беларуская (тарашкевіца)‬ ...

Coded Smorgasbord: Schizophrenic Haiku Comments and More
... writes Malcom StandardResponse UnSubscribeNewsletterUserAccount( string opTinGUID,string email, string sellingRegion, string source, DateTime ... - Welkom op de site van de provincie Limburg - Welkom_op_de_site_van_de_provincie_Limburg
visit wonen werken leven ontspannen infopunt home op trefwoord contactpersonen wegwijs sitemap print deze pagina Je bent hier: Contact ...

Simples Ideias. Por Nando Vieira.
Simples Ideias Siga-me no Twitter Junho/2012 Usando o Vagrant como ambiente de desenvolvimento no Windows ...

Resources last updated: 11/21/2015 6:25:41 PM