August 30, 2005 at 7:45 am
HI,
I am inserting info from a join query into a single table. There is nowhere in the join results that actually has todays date. In the destination table I have added a column so that I can insert todays date. What syntax do I need to use to add todays date to a specific column of a table?
thanks,
Paul
August 30, 2005 at 7:48 am
You can add a default to that column (GetDate()), so you wouldn't have to specify it in the insert/select.
August 31, 2005 at 12:48 am
GetDate() will return the current date and time.
If you want just the date without the time:
CAST( CONVERT( CHAR(8), GetDate(), 112) AS DATETIME)
Julian Kuiters
juliankuiters.id.au
August 31, 2005 at 4:16 am
DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0) keeps the date only converison numeric
Try it over a dummy table of 10000 rows etc... quicker
August 31, 2005 at 6:45 am
Check this out for more details on performance conversions :
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=215358&p=2
August 31, 2005 at 6:54 am
If you want just the date, use an ODBC canonical function
select {fn CURRENT_DATE()} AS 'date only'
or
SELECT {fn CURRENT_TIMESTAMP()} AS 'Timestamp'
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcscalar_functions.asp for more information on ODBC functions.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy