| Author |
Topic |
|
siti
Starting Member
11 Posts |
Posted - 2005-08-11 : 23:02:35
|
| i have an application that stores data using dd/mm/yyyy format. how can i select data by month only? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-12 : 00:56:58
|
| Which of the following do you want?Select columns from yourTable where month(datecol)=monthvalueSelect month(datecol) from yourtableMadhivananFailing to plan is Planning to fail |
 |
|
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2005-08-12 : 01:11:56
|
| Select *From tblYourTableWhere DATEDIFF(MM, dtiYourDateField, @dtiPassedInDate) = 0AjHey, it compiles. |
 |
|
|
siti
Starting Member
11 Posts |
Posted - 2005-08-12 : 03:54:28
|
| i think i'll use the first one madhivanan. Select columns from yourTable where month(datecol)=monthvaluehow should i write the monthvalue? eg: august or 8 |
 |
|
|
siti
Starting Member
11 Posts |
Posted - 2005-08-12 : 04:06:49
|
| aj,what do you mean by @dtiPassedInDate |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-12 : 04:42:30
|
| >>how should i write the monthvalue? eg: august or 8Select columns from yourTable where month(datecol)=8MadhivananFailing to plan is Planning to fail |
 |
|
|
siti
Starting Member
11 Posts |
Posted - 2005-08-12 : 05:45:31
|
| i tried your opinion madhivanan but i get error like this:error converting datetime statement to varchar statement |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-12 : 05:47:12
|
| Post the table structure and the actual query you usedMadhivananFailing to plan is Planning to fail |
 |
|
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2005-08-12 : 10:05:13
|
| I was assuming that you are passing in a date field to query against. If it just has to pull this months records then use this:Select *From tblYourTableWhere DATEDIFF(MM, dtiYourDateField, GETDATE()) = 0And like madhivanan suggested, if we aren't giving you what you are looking for then go ahead and post the table structure.AjHey, it compiles. |
 |
|
|
siti
Starting Member
11 Posts |
Posted - 2005-08-18 : 01:36:28
|
| thanks everybody... i've tried both solution and it worked. sorry because i send late reply. anyway...thank you so much. |
 |
|
|
|