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
 How do I format text date to date/time?

Author  Topic 

wures7
Starting Member

2 Posts

Posted - 2011-02-02 : 18:41:19
Hello all. I need some help. I'm trying to create a report where I can use the calander picker in SSRS. The problem is when I change the data type for my parameters from text to date/time to give me the calendar picker, it breaks my script. When the data type is text, I would enter a range of dates in the YYYY.MM.DD format in an empty field and it would give me my report.

Here is my script.

SELECT Username, [Start Time], Duration / 60 AS Minutes, Service, Active, Auth, [Real Ip], [Vpn Ip], Proto, Port, [Bytes Total]/1048576 AS Megabytes
FROM log_report_csv
WHERE [Start Time] >= @StartDate AND [Start Time] <= @EndDate + '23:59:59'

The data in the [Start Time] column shows in this format:
2011.01.30 16:59:55 PST

So now, my problem is how do I modify my script so that the calendar picker will work with this script?

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2011-02-03 : 01:27:14
what is the data type of the column START TIME in your table?
Go to Top of Page

wures7
Starting Member

2 Posts

Posted - 2011-02-03 : 13:44:17
The data type is text.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-04 : 05:16:07
Use proper DATETIME datatype to store dates

WHERE CAST([Start Time] as DATETIME) >= @StartDate AND CAST([Start Time] as DATETIME) <= @EndDate + '23:59:59'

Madhivanan

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

- Advertisement -