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 |
|
blackinwhite
Starting Member
10 Posts |
Posted - 2004-08-06 : 09:41:38
|
while I store the dates as is in db,I can use a select statement like thisquote: mySQL="SELECT SUM(total) AS totalSum, month(orderdate) AS monthsql FROM orderDetails GROUP BY MONTH(orderdate)"
but when I use dates as integer, it simply gives me error.Are there any way of getting over that problem?Any solution? |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2004-08-06 : 11:00:59
|
| Why do you want to store the dates as INT?Mark |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-08-06 : 11:42:07
|
| Why do you feelMonth(<some integer value>)should return a valid value w/o some sort of conversion? What do you feel that Month(-923456) should return?I always tell people: forget about what you THINK the computer SHOULD understand; put yourself in the computer's shoes, forget about the fact that YOU know that you intend for that integer column to be interpreted as a date (in a format that only YOU know) and look at the situation that way. If you are working with computers for a living, it would definitely help to adapt that way of thinking. - Jeff |
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-08-06 : 12:22:13
|
The solution is to not store dates as integers Dustin Michaels |
 |
|
|
blackinwhite
Starting Member
10 Posts |
Posted - 2004-08-09 : 08:48:01
|
quote: Originally posted by DustinMichaels The solution is to not store dates as integers Dustin Michaels
nop, wrong answer. :)using substring solved my problem.mySQL="SELECT SUM(convert(int,total)) AS totalSum, substring(orderdateInt, 5, 2) AS monthsql FROM orderDetails GROUP BY substring(orderDateInt, 5, 2)" |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-09 : 09:28:38
|
| well if you have dates in format: yyyymmdd you can simply use convert.Go with the flow & have fun! Else fight the flow :) |
 |
|
|
|
|
|
|
|