Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help!How to show DATE only

Author  Topic 

Aramis
Starting Member

13 Posts

Posted - 2009-09-22 : 21:08:21
Guys,

I'm a newbie in SQL, I have a data that i set in datetime in SQL, how could i rid off the time and i want it the date show in my vb.net? thanks for the help

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-09-22 : 21:43:27
There's a format function of some kind in VB.Net (it was...wait for it...Format() in VB, not sure about VB.Net). If that won't float your boat:

SELECT CONVERT(char(10), dateValue, 101) dateVal FROM myTable

Look up the CONVERT() function in SQL Server Books Online for more information on different date formats.
Go to Top of Page

Aramis
Starting Member

13 Posts

Posted - 2009-09-22 : 21:48:30
thanks a lot, let me try this one...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-23 : 02:47:15
In VB.NET it is something like

date_var.tostring("MM/dd/yyyy")

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Aramis
Starting Member

13 Posts

Posted - 2009-09-24 : 04:36:12
thanks madhivanan
Go to Top of Page

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-24 : 10:24:13
Select convert(DateTime, Convert(VarChar(10), dateValue, 112))

[ /fail at humor]
Go to Top of Page

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-24 : 10:26:23
Fail...
[ /fail at humor]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-24 : 10:27:30
quote:
Originally posted by winterh

Select convert(DateTime, Convert(VarChar(10), dateValue, 112))

[ /fail at humor]


I dont think OP needed this
Anyway alternate method is

select dateadd(day,datediff(day,0,dateValue),0)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-24 : 10:30:02
quote:
Originally posted by winterh

Then MID(1, 9, dateValue)

[ /fail at humor]


MID wont work in SQL Server
Alternate is SUBSTRING

[/fail at query]

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-24 : 10:32:44
Dang, I got owned again! Sorry, it's best if the newbs ignore my replies lol. Dang.

[ /fail at query]
Go to Top of Page
   

- Advertisement -