Click here to Skip to main content
15,886,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to save records with todays date as 18-12-2012 12:00:00 AM.while using getdate function current time is saving,but i need dafult time as 12:00:00 AM
Posted

no direct function in SQL 2005
so, use below query
SQL
select convert(datetime,convert(varchar(10),getdate(),102))

Happy Coding!
:)
 
Share this answer
 
Comments
josh-jw 18-Dec-12 1:30am    
thnx for reply.also we can go for like these.DATEADD(DAY, DATEDIFF(day, 0, GETDATE()), 0)
Aarti Meswania 18-Dec-12 1:36am    
Welcome! :)

yes you are right,
it's also a way...
but as i said no direct way or direct function in sql.
we have to process getdate() function of sql for this final output
i have use convert function, you used dateadd right? :)

Glad to help you! :)
Have a nice day! :)
refer this site for you assistance

http://www.w3schools.com/sql/func_date_format.asp[^]
 
Share this answer
 
Select right(CONVERT(VARCHAR, GETDATE(), 100),7)

if wants only date then put left at the place of right in the query
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900