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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Date portion of date

Author  Topic 

baska123
Yak Posting Veteran

64 Posts

Posted - 2007-08-16 : 16:13:38
Date is saved in a format of date and time. I just want the date portion of it.

select pp.APPROVE_DT ....................

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-16 : 16:14:32
SELECT DATEADD(d,1,DATEDIFF(d,0,YourDateColumn))

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-16 : 16:18:37
Tomorrow's date, dinakar?

SELECT DATEADD(day, DATEDIFF(day, 0, YourDateColumn), 0)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

baska123
Yak Posting Veteran

64 Posts

Posted - 2007-08-16 : 16:18:59
Date looks like that
8/15/2007 3:51:24 PM

and I want it in this format
8/15/2007
Go to Top of Page

ashley.sql
Constraint Violating Yak Guru

299 Posts

Posted - 2007-08-16 : 16:20:52
select convert(varchar(10), getdate(), 110)

Ashley Rhodes
Go to Top of Page

ashley.sql
Constraint Violating Yak Guru

299 Posts

Posted - 2007-08-16 : 16:21:21
sorry that was a typo

select convert(varchar(10), getdate(), 101)

Ashley Rhodes
Go to Top of Page

ashley.sql
Constraint Violating Yak Guru

299 Posts

Posted - 2007-08-16 : 16:22:00
OR

select convert(varchar(10), '8/15/2007 3:51:24 PM', 101)

you can replace getdate() with your column name

Ashley Rhodes
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-16 : 20:42:50
quote:
Originally posted by Peso

Tomorrow's date, dinakar?

SELECT DATEADD(day, DATEDIFF(day, 0, YourDateColumn), 0)



E 12°55'05.25"
N 56°04'39.16"



oops.. cut/paste error...

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-16 : 22:43:03
quote:
Originally posted by baska123

Date looks like that
8/15/2007 3:51:24 PM

and I want it in this format
8/15/2007



use Dinakar method to remove the time component of the date. Format your date in your front end. Not in SQL.
[spoiler]Copyright Madhi[/spoiler]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-17 : 02:19:36
quote:
Originally posted by baska123

Date looks like that
8/15/2007 3:51:24 PM

and I want it in this format
8/15/2007


Where do you want to show fomratted dates?

Madhivanan

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

- Advertisement -