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
 SQL 2000 convert date to UK

Author  Topic 

ahaile
Starting Member

25 Posts

Posted - 2010-11-17 : 11:35:59
I am working on a report using Microsoft Report Designer (VS 2005). I am trying to creat a parameter for start date and end date for UK users in UK time format. I need to build a parameter to display in UK DATE format (yyyy/mm/dd). Then I need to pass the selected UK @startdate and @enddate into the main SQL query in US time format (yyyy/dd/mm).

Here is my prameter:
Select distinct CONVERT(VARCHAR(11),startdate,103)as startdate
from table
where @startdate > '2010/20/10' 'US DATE FORMATE
and order by startdate

Here is the expected Result:
startdate (no duplicate startdate needed)
2010/21/10
2010/22/10
2010/23/10
2010/24/10
.
.
.

Here is my main sql:
select * from table2
where @startdate between @startdate and @enddate

I appriciate any assitant or direction on this.



Expected value for @startdate and @enddate is US date format.

Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-17 : 12:34:49
I don't understand the question

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

ahaile
Starting Member

25 Posts

Posted - 2010-11-17 : 13:26:44
Brett - I need to run a SQL query that returns dates in UK format from SQL 2000 database (The dates in the database are in US format). Then I need to use the UK returned date as variable to run another SQL statemnt, but prior to running the second SQL query I need to convert the dates back to US.

Does this makes sense?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-17 : 13:42:42
well....

Dates are stored internally as 2 separate int values

You can look up cast and convert in books online and pick what ever format you want

..But is this what you need

SELECT CONVERT(varchar(26),GetDate(),111)

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-18 : 06:09:57
Make sure you read this
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-ii.aspx

Madhivanan

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

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-18 : 09:35:25
The link to part 1 is broken...do you have that link?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-18 : 10:11:13
quote:
Originally posted by X002548

The link to part 1 is broken...do you have that link?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/





This is part 1
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-i.aspx



Madhivanan

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

- Advertisement -