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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 remove time stamp from the Today function

Author  Topic 

gemini_shooter
Starting Member

12 Posts

Posted - 2008-11-17 : 16:27:55
Hello,

I am trying to remove the timestamp from the today function, unfortuantely have been unable to find a function which just returns the date without the timestamp.

Can you please guide me in a direction.

Thanks
gemini_shooter

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-11-17 : 16:57:29
[code]
select
[current_timestamp] = current_timestamp,
[current_date] = dateadd(dd,datediff(dd,0,current_timestamp),0)


Results:
current_timestamp current_date
----------------------- -----------------------
2008-11-17 16:56:59.403 2008-11-17 00:00:00.000

(1 row(s) affected)


[/code]

CODO ERGO SUM
Go to Top of Page

gemini_shooter
Starting Member

12 Posts

Posted - 2008-11-17 : 17:17:55
Thanks Michael,

is there way I can do it in expressions and not TSQL
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-18 : 04:54:29
quote:
Originally posted by gemini_shooter

Thanks Michael,

is there way I can do it in expressions and not TSQL


What do you mean by expressions?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-18 : 05:18:41
If by expression you mean function, I don't think there is.
Go to Top of Page

gemini_shooter
Starting Member

12 Posts

Posted - 2008-11-18 : 21:25:15
I feel so stupid but it was just a matter of formating date timestamp into a 'd' to remove the timestamp.

Thanks a lot guys ...
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-19 : 01:30:24
You can use this query also...
in place of 105, you can use several numbers like 101,102......upto 121
select convert(varchar(25),getdate(),105)
select convert(varchar(12),getdate(),113)


Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-19 : 02:14:40
quote:
Originally posted by sunsanvin

You can use this query also...
in place of 105, you can use several numbers like 101,102......upto 121
select convert(varchar(25),getdate(),105)
select convert(varchar(12),getdate(),113)


Arnav
Even you learn 1%, Learn it with 100% confidence.


Nope. dont change datatype just for presenation formatting. its simply a matter of handling this at front end application where you have functions avaialable for this
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-20 : 01:27:38
quote:
Originally posted by sunsanvin

in place of 105, you can use several numbers like 101,102......upto 121


Arnav
Even you learn 1%, Learn it with 100% confidence.


Not True

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-20 : 01:32:29
see this for available values

http://msdn.microsoft.com/en-us/library/ms187928(SQL.90).aspx
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-20 : 01:53:44
quote:
Originally posted by madhivanan

quote:
Originally posted by sunsanvin

in place of 105, you can use several numbers like 101,102......upto 121


Arnav
Even you learn 1%, Learn it with 100% confidence.


Not True

Madhivanan


Madhi, can you please correct me here.....
i've tested for different values.... and working fine for me

Failing to plan is Planning to fail



Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-20 : 02:07:49
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80563



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-20 : 02:15:50
Simply Superb...
thanks for the clarification peso....

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-20 : 04:00:10
quote:
Originally posted by sunsanvin

quote:
Originally posted by madhivanan

quote:
Originally posted by sunsanvin

in place of 105, you can use several numbers like 101,102......upto 121


Arnav
Even you learn 1%, Learn it with 100% confidence.


Not True

Madhivanan


Madhi, can you please correct me here.....
i've tested for different values.... and working fine for me

Failing to plan is Planning to fail



Arnav
Even you learn 1%, Learn it with 100% confidence.




select convert(varchar(25),getdate(),115)
select convert(varchar(25),getdate(),116)
select convert(varchar(25),getdate(),117)
etc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -