Home > Archive > MS SQL Server > July 2005 > Re: insert only date









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: insert only date
Wojtek Garwol

2005-07-27, 8:23 pm

"JIM.H." <JIMH@discussions.microsoft.com> wrote in message
news:27606F13-199E-45F1-9E12- B1232845A907@microso
ft.com...
> In a stored procedure;
>
> INSERT INTO myTable(myDate) VALUES (@myDate)
>
> This inserts data and time, is there any way I can only insert date
> portion
> of DateTime


Is "myDate" field of datetime type or of varchar type?

If datetime, all you can do is to "truncate" the date to the midnight:

2005-07-27 21:17:41.123 -> 2005-07-27 00:00:00.000

and you do this so:

convert(datetime, substring(convert(va
rchar, @myDate, 120), 1, 10), 120)

if it is varchar then

substring(convert(va
rchar, @myDate, 120), 1, 10)

Cheers,
Wojtek


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com