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.
| Author |
Topic |
|
steamngn
Constraint Violating Yak Guru
306 Posts |
Posted - 2005-02-24 : 11:15:42
|
Hi again,I need to store the current time in a column, and am having a mental moment:here is the current code: CONVERT(VARCHAR,GETDATE(),108) It is storing the value as:1/1/1900 11:09:19 AM What I need is:11:09:19 AM I KNOW I'm forgetting something stupid, but can't remember what it is...AndyThere's never enough time to type code right, but always enough time for a hotfix... |
|
|
NoNulls
Starting Member
14 Posts |
Posted - 2005-02-24 : 12:13:40
|
| uh, datepart? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-02-24 : 12:15:49
|
| Datetime values always stores date AND time info...by using 108, it gets the time, AND stores the date as 0, or 1/1/1900....If you want, just store it in varchar...but you're better off using datetime and the displaying the data using convertBrett8-) |
 |
|
|
steamngn
Constraint Violating Yak Guru
306 Posts |
Posted - 2005-02-24 : 12:48:06
|
| Hey Brett,I am SO out of it today..(getting over one nasty cold).I'm missing something still. Do I need to set the column to VARCHAR(8) to store just the time? This is one of those stupid-ass Crystal Report deals...AndyThere's never enough time to type code right, but always enough time for a hotfix... |
 |
|
|
steamngn
Constraint Violating Yak Guru
306 Posts |
Posted - 2005-02-24 : 14:16:47
|
Ok Brett,took a nap and figured it out...cast(CONVERT(VARCHAR,GETDATE(),108)as varchar(8)) Thanks for the help!AndyThere's never enough time to type code right, but always enough time for a hotfix... |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-02-25 : 10:59:07
|
| Doesn't crystal have the abiliy to format Datetime to Time?Brett8-) |
 |
|
|
steamngn
Constraint Violating Yak Guru
306 Posts |
Posted - 2005-02-25 : 12:02:13
|
Yeah,it does. BUT, what needs to happen here is this:The report has a date range parameter. Inside this report is a subreport that has a time range parameter. the time range parameter is not always within the date range parameter (So I guess this is really a Management problem; goody! I get to smack someone!), so I need to have the datetime query twice. I tried about a gabillion ways to just use the datetime column that I am using for the main report query, then gave up and called Crystal support. "Oh yeah, time parameters in a subreport need to have just a time column to read. Don't really know why it does that."SO.....Here I am, playing with dates and times....It works fine now, by the way. I sent the report in from home, and of course I forgot to format the time to a 12h clock, so they were already complaining about that..Andy There's never enough time to type code right, but always enough time for a hotfix... |
 |
|
|
|
|
|
|
|