| Author |
Topic |
|
smitha
Posting Yak Master
100 Posts |
Posted - 2010-01-06 : 06:24:12
|
| how to get the system date in sqlSmitha |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-01-06 : 06:25:44
|
| SELECT GETDATE()- Lumbagohttp://xkcd.com/327/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-06 : 06:29:20
|
| alsoSELECT CURRENT_TIMESTAMP |
 |
|
|
shan
Yak Posting Veteran
84 Posts |
Posted - 2010-01-06 : 11:07:53
|
| alsoselect {fn Now()} |
 |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2010-01-06 : 11:51:40
|
| I've never seen this last one personally Shan, I noticed that the brackets are required, does that tell SQL it's a system function of some sort? If you don't mind can you just explain this one quickly, I cant find it using the help explorer! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-06 : 11:58:26
|
quote: Originally posted by DP978 I've never seen this last one personally Shan, I noticed that the brackets are required, does that tell SQL it's a system function of some sort? If you don't mind can you just explain this one quickly, I cant find it using the help explorer!
its the ODBC canonical function. there are also other functions like{fn CURRENT_TIMESTAMP()} ,{fn CURRENT_DATE()},{fn CURRENT_TIME()} |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-06 : 12:13:42
|
However - Lumbago's reply is enough for the OP  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-06 : 12:16:15
|
quote: Originally posted by webfred However - Lumbago's reply is enough for the OP  No, you're never too old to Yak'n'Roll if you're too young to die.
But he got quite a bit of handy info |
 |
|
|
shan
Yak Posting Veteran
84 Posts |
Posted - 2010-01-06 : 12:18:49
|
yes some more ways of doing things |
 |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2010-01-06 : 12:33:57
|
| Do people use {fn CURRENT_DATE()} instead of the convert(varchar(10),GetDate(), 101) at all? Or is it safer to just use getdate() |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-06 : 12:39:31
|
quote: Originally posted by DP978 Do people use {fn CURRENT_DATE()} instead of the convert(varchar(10),GetDate(), 101) at all? Or is it safer to just use getdate()
You can use both. I've not heard of any reasons that forbids you from using canonical funtions. |
 |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2010-01-06 : 12:53:10
|
| Awesome, thanks for the info. I will most likely remember GetDate() first and foremost, but just in case I use the other I wanted to make sure I was not hurting my query performance. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-07 : 01:53:34
|
quote: Originally posted by visakh16
quote: Originally posted by DP978 I've never seen this last one personally Shan, I noticed that the brackets are required, does that tell SQL it's a system function of some sort? If you don't mind can you just explain this one quickly, I cant find it using the help explorer!
its the ODBC canonical function. there are also other functions like{fn CURRENT_TIMESTAMP()} ,{fn CURRENT_DATE()},{fn CURRENT_TIME()}
Some moreselect {fn current_date()}select {fn current_time()}select {fn now()}select {fn extract(hour from getdate())}select {fn extract(minute from getdate())}select {fn extract(second from getdate())}select {fn extract(day from getdate())}select {fn extract(month from getdate())}select {fn extract(year from getdate())}select {fn dayname(GetDate())}select {fn monthname(GetDate())}select {fn month(GetDate())}select {fn year(GetDate())}MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-07 : 01:59:59
|
quote: Originally posted by madhivanan
quote: Originally posted by visakh16
quote: Originally posted by DP978 I've never seen this last one personally Shan, I noticed that the brackets are required, does that tell SQL it's a system function of some sort? If you don't mind can you just explain this one quickly, I cant find it using the help explorer!
its the ODBC canonical function. there are also other functions like{fn CURRENT_TIMESTAMP()} ,{fn CURRENT_DATE()},{fn CURRENT_TIME()}
Some moreselect {fn current_date()}select {fn current_time()}select {fn now()}select {fn extract(hour from getdate())}select {fn extract(minute from getdate())}select {fn extract(second from getdate())}select {fn extract(day from getdate())}select {fn extract(month from getdate())}select {fn extract(year from getdate())}select {fn dayname(GetDate())}select {fn monthname(GetDate())}select {fn month(GetDate())}select {fn year(GetDate())}MadhivananFailing to plan is Planning to fail
just as a query, have you heard of any points that suggests not to use this? I've not heard any myself. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-07 : 02:11:36
|
quote: Originally posted by visakh16
quote: Originally posted by madhivanan
quote: Originally posted by visakh16
quote: Originally posted by DP978 I've never seen this last one personally Shan, I noticed that the brackets are required, does that tell SQL it's a system function of some sort? If you don't mind can you just explain this one quickly, I cant find it using the help explorer!
its the ODBC canonical function. there are also other functions like{fn CURRENT_TIMESTAMP()} ,{fn CURRENT_DATE()},{fn CURRENT_TIME()}
Some moreselect {fn current_date()}select {fn current_time()}select {fn now()}select {fn extract(hour from getdate())}select {fn extract(minute from getdate())}select {fn extract(second from getdate())}select {fn extract(day from getdate())}select {fn extract(month from getdate())}select {fn extract(year from getdate())}select {fn dayname(GetDate())}select {fn monthname(GetDate())}select {fn month(GetDate())}select {fn year(GetDate())}MadhivananFailing to plan is Planning to fail
just as a query, have you heard of any points that suggests not to use this? I've not heard any myself.
I dont know. Also there is no proper documentation in BOLMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-07 : 02:20:21
|
Oh ok. Just checked |
 |
|
|
balaganapathy.n
Starting Member
18 Posts |
Posted - 2010-01-07 : 07:56:00
|
quote: Originally posted by shan alsoselect {fn Now()}
Thanks, shan, vishak, madhi that was new one to me.balaganapathy n.Anything you can imagine is real. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-07 : 08:00:14
|
quote: Originally posted by balaganapathy.n
quote: Originally posted by shan alsoselect {fn Now()}
Thanks, shan, vishak, madhi that was new one to me.balaganapathy n.Anything you can imagine is real.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|