April 24, 2007 at 3:12 pm
How can I convert a date to the format yyyymmdd, so that from SELECT getdate () it would appear as 20070424 ?
Thanks...Nali
April 24, 2007 at 4:39 pm
select convert(char(8), getdate(), 112)
April 27, 2007 at 8:37 pm
Hi,
assume you have a table with four columns (v_start, v_end, t_start, t_end) which are date (dd-mon-yy). how to convert these date to number?
thanks in advance.
April 27, 2007 at 10:46 pm
Hi All
I too have a problem with date values comparision... the below is the code
CONVERT(VARCHAR(30),TRANS_DATE,101)>(@REPORTDATE)
where @REPORTDATE is declared as DATETIME
this condition is working in some of the data bases and its not working in some other databases.....
Are there any settings to be performed in order to do this...?????.
April 29, 2007 at 5:57 am
- advised is to use the (small of needed) datetime format because of datatype and engine-handling.
- So in stead of querying CONVERT(VARCHAR(30),TRANS_DATE,101)>(@REPORTDATE) just use
TRANS_DATE> convert(datetime,@REPORTDATE, 101)
The reason for this is that you always should convert your variables to the datatype of the column in the table you are using. If an index on that column exists, the engine will use the index whereas it will not use the index - at least less optimal - when you convert to column to something else.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply