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
 Setting datetime variable w/ mm/dd/yyyy

Author  Topic 

tmaiden
Yak Posting Veteran

86 Posts

Posted - 2007-07-19 : 12:17:45
I am having the wrost trouble with this today for some dumb reason...
Please don't suggest any alternates; this is just a quick example, full code is more elaberate.

Today is 07/19/2007
Declare @StartDate DateTime
@StartDate = CONVERT(VARCHAR(10), Month(GetDate()) & "/22/" & Year(GetDate()), 101)

So I want @StartDate = '07/22/2007'

What I need is CDate

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-07-19 : 12:29:47
Are you trying to do this in T-SQL or VB? You have a mix of the commands.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-07-19 : 13:38:45
quote:
Originally posted by tmaiden
...Please don't suggest any alternates...

OK.


CODO ERGO SUM
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-19 : 15:57:15
I just can't resist

SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, CURRENT_TIMESTAMP), 21)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

thewebhostingdir
Starting Member

3 Posts

Posted - 2007-07-20 : 00:29:02
I think...

select convert(varchar,DateColumn,101)

will work

-------------------------
Jason P.
AccuWebHosting.Com
SQL 2005/2008 Web Hosting
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-07-20 : 01:30:48
<<
Please don't suggest any alternates;
>>

Why?

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-20 : 06:37:54
quote:
What I need is CDate

Will MDate do ?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=22339&SearchTerms=MDate

[EDIT]Oops sorry, that is an alternative, i better removed it[/EDIT]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -