Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi all,i want to truncate the date Eg. if my date is 07/01/2008 then i want out put 01/01/2008orif my date is 12/01/2008 then i want out put 01/01/2008how can i get this result.Pankaj
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-05-10 : 02:30:11
if your posted date was in dd/mm/yyyy format then use below
SELECT DATEADD(mm,DATEDIFF(mm,0,Yourdateval),0) if its in mm/dd/yyyy then use belowSELECT DATEADD(yy,DATEDIFF(yy,0,Yourdateval),0)
pmotewar
Yak Posting Veteran
62 Posts
Posted - 2009-05-10 : 03:19:24
quote:Originally posted by visakh16 if your posted date was in dd/mm/yyyy format then use below
SELECT DATEADD(mm,DATEDIFF(mm,0,Yourdateval),0) if its in mm/dd/yyyy then use belowSELECT DATEADD(yy,DATEDIFF(yy,0,Yourdateval),0)