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 |
|
ryoka012
Starting Member
20 Posts |
Posted - 2012-09-03 : 22:45:09
|
| Hi Guys,Could anyone help me with the datetime computation.Here is the scenarioi have declared a @mydate as dateimeand i have default value of a Column Startdate of 9/3/2012 12:00:00 AM.i tried to use computation @mydate - Startdate.and i have a value of '1900-01-02 10:42:29.890'.my question is how can i convert this value in to non confusing value.Thanks a lot. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-03 : 23:34:33
|
| what do you mean by non confusing valuealso try to pass datevalues in non ambiguos format9/3/2012 12:00:00 AM. can represent 3rd of September or 9th or March depending on locale settings so better to pass values in YYYYMMDD formatseehttp://visakhm.blogspot.com/2011/12/why-iso-format-is-recommended-while.htmlalso whats the unit in which you're trying to represent the difference ie hours,minutes etc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
ryoka012
Starting Member
20 Posts |
Posted - 2012-09-03 : 23:47:38
|
| Thanks for the reply Visakh16What i mean is i will if i have a value of getdate=9/1/2012 12:00:00 AM and startdate=9/3/2012 12:00:00 AMand get the difference value like getdate-startdate i will have a value of 1900-01-02 10:42:29.890 which is confusing. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-09-04 : 09:11:04
|
| What do you want to return as a date?MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-05 : 21:26:49
|
quote: Originally posted by ryoka012 Thanks for the reply Visakh16What i mean is i will if i have a value of getdate=9/1/2012 12:00:00 AM and startdate=9/3/2012 12:00:00 AMand get the difference value like getdate-startdate i will have a value of 1900-01-02 10:42:29.890 which is confusing.
hmm?why should you return difference as date value?why not return it as integer value (2 days)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|