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
 short diplay for Datetime type

Author  Topic 

pitt1
Starting Member

16 Posts

Posted - 2006-06-13 : 05:38:20
Hi all,
I have a view with a datetime column,
when viewing the column data the format is:

" 2006-06-12T12:00:00.0000000+03:00 "

while i'm only want to see the date part

(that is, 2006-06-12, and if possible in the format: dd/mm/yyyy)
now, when i'm using convert( varchar(10), [column_name],101)
i'm getting the format i need but the problem is that i'm
"losing" the date type, is it possible to view it as the
format i stated and still as a datetime type ??

Regards,
Pit

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-13 : 05:46:41
Where do you want to show the converted dates? If you use front end application, do the formation there. Otherwise use this to omit time part

Select DateAdd(day,Datediff(day,0,column_name),0) from yourTable

Madhivanan

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

pitt1
Starting Member

16 Posts

Posted - 2006-06-14 : 08:13:25
i've tried :
select DateAdd(day,Datediff(day,0, [my_col_name] ),0) from my_table

but it still shoes the data in "2004-12-18 00:00:00.000" format

Thanks,
P.
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-06-14 : 08:20:19
quote:
is it possible to view it as the format i stated and still as a datetime type ??
No - you can't do this, so what you want isn't possible.

If Madhivanan's suggestions don't work for you, perhaps you could explain why you want to do this. We might then have some other suggestions...



Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-14 : 08:47:29
quote:
Originally posted by pitt1

i've tried :
select DateAdd(day,Datediff(day,0, [my_col_name] ),0) from my_table

but it still shoes the data in "2004-12-18 00:00:00.000" format

Thanks,
P.



I asked you "Where do you want to show the converted dates?"

Madhivanan

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

pitt1
Starting Member

16 Posts

Posted - 2006-06-15 : 05:39:31
Forgive me if I wasn’t clear before,

I have a view in sql server, using this view I want to display a certain column of datetime type
in a short display (only the date part) and still be
Able to “order by� the view output by this datetime column,
if (inside the view), I’ll use:

Seletct convert( varchar(10), [column_name],101) as [x] from my_tbl

I won’t be able to do the “order by“ on the datime column later on, since the data is a char data,

I want the converted dates to be shown in a windows share point site (using a dataview)

Hope I was clear enough,
P.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-15 : 05:57:40
>>I want the converted dates to be shown in a windows share point site (using a dataview)

Cant you format date there?(I dont know about windows share point)
or use convert function as you used

Madhivanan

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

- Advertisement -