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.
| Author |
Topic |
|
nic
Posting Yak Master
209 Posts |
Posted - 2002-01-02 : 14:23:54
|
| Hi,I'm writing a sp that builds a sql statement using the getdate function, but it only returns the date and time to the minute. How can you get the seconds to be included? I also tried current_timestamp but it returned the same value. Simple example:CREATE PROCEDURE testSPASprint 'select * from table where date = ' + cast(current_timestamp As varchar)GOI tried char etc but it never returns the seconds.Thanks in advanceNic |
|
|
Rita Bhatnagar
Posting Yak Master
172 Posts |
Posted - 2002-01-02 : 14:28:37
|
| look at convert function in bol. |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-01-03 : 16:50:10
|
| Why are you CASTing a datetime value as varchar? Is your date field in your table not of datetime data type? If you select getdate() or current_timestamp without casting it as a varchar you will get seconds and 3/1000 of seconds. Try your statement without the CAST.--------------------------------------------------------------1000 Posts, Here I come! I wonder what my new title will be... |
 |
|
|
Rafiq
Starting Member
25 Posts |
Posted - 2002-01-04 : 03:35:50
|
| Hi,It's not a big problem. Try to use GetDate(). It will solve your problem.Regards,Rafi |
 |
|
|
ymurali
Starting Member
2 Posts |
Posted - 2002-01-04 : 06:02:14
|
quote: Hi,I'm writing a sp that builds a sql statement using the getdate function, but it only returns the date and time to the minute. How can you get the seconds to be included? I also tried current_timestamp but it returned the same value. Simple example:CREATE PROCEDURE testSPASprint 'select * from table where date = ' + cast(current_timestamp As varchar)GOI tried char etc but it never returns the seconds.Thanks in advanceNic
|
 |
|
|
ymurali
Starting Member
2 Posts |
Posted - 2002-01-04 : 06:04:00
|
Hiu better check the version of sqlserver u r using,if i do a getdate() in sqlserver7.0 the output is 2002-01-04 10:56:35.457muraliquote: Hi,I'm writing a sp that builds a sql statement using the getdate function, but it only returns the date and time to the minute. How can you get the seconds to be included? I also tried current_timestamp but it returned the same value. Simple example:CREATE PROCEDURE testSPASprint 'select * from table where date = ' + cast(current_timestamp As varchar)GOI tried char etc but it never returns the seconds.Thanks in advanceNic
|
 |
|
|
|
|
|