August 3, 2011 at 12:45 am
Hello friends ! this is my first topic on this forum !!
I am in trouble.. I am developing a web application using ASP.Net with C# and SQL Server 2005. I don't want to show date part where I want to show only time and vice versa. But all peoples on web suggesting me to convert it into varchar and all that... But my problem is the variable which I am assigning the result is datetime type so cant assign varchar converted result to it (Don't tell me take varchar type variable as I don'y have access to change it. Iis in a DLL).
I hope my English is capable to describe my problem. Thanks in advance.
August 3, 2011 at 1:20 am
http://www.sqlservercentral.com/scripts/DateTime/61691/
This returns just the date, although time is still present as 00:00:00. See the discussion for that article for further examples.
BrainDonor.
August 3, 2011 at 6:12 am
Ya but you can format the date to whatever you want once in ASPX. I would search there rather than SQL side.
August 3, 2011 at 6:29 am
Please try this
SELECT DATEADD(dd,DATEDIFF(dd,0,getdate()),0)
Which will give the date with no time.
2011-08-03 00:00:00.000
Prakash Machiraju
August 3, 2011 at 7:17 am
Ninja's_RGR'us (8/3/2011)
Ya but you can format the date to whatever you want once in ASPX. I would search there rather than SQL side.
I agree with this - it seems to me that this is a presentation issue, not a storage/retrieval issue.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
August 3, 2011 at 5:27 pm
Format it in your C# code, see: http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=VS.100).aspx#Y480
There are standard date/time formats available, but this should give you a good idea on how to accomplish this in your code.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply