PDA

View Full Version : دستور sql : beetween



هواشناس
شنبه 18 مهر 1388, 12:21 عصر
بنام خدا
با سلام
دستور زير از sql رو چطوري اصلاح كنم جواب بده البته فقط قسمت شرط where ايراد داره
كه در اون StationCodes نام جدول و gdate‌نام فيلد از نوع shortdate و Mydate1 متغير تاريخ هست
به سه مدل نوشتم نشد:


StationCodes&"."&"gdate beetween '"&dateadd("yyyy",-1,cdate(MyDate1))&"'"&" and "&"'"&cdate(MyDate1)&"'"
StationCodes&"."&"gdate beetween '#"&dateadd("yyyy",-1,cdate(MyDate1))&"#'"&" and "&"'#"&cdate(MyDate1)&"#'"
StationCodes&"."&"gdate>=#"&dateadd("yyyy",-1,cdate(MyDate1))&"#"&" and "&StationCodes(0)&"."&"gdate<=#"&cdate(MyDate1)&"#"

اين هم ايرادش البته براي مدل اولي



Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression '[40768].gdate beetween '2009/10/20' and '2010/10/20' and [90530].gdate beetween '2009/10/20' and '2010/10/20' and [40775].gdate beetween '2009/10/20' and '2010/10/20' and [40886].gdate beetween '2009/10/20' and '2010/10/20' and [99384].gdate beetween '200'.

kashaneh
یک شنبه 19 مهر 1388, 20:36 عصر
دوست عزیز چند نکته :

1 - فرمت تاریخ در فیلد شما به صورت سال/روز/ماه می باشد (مثال 10/20/2009 )
2 - از between و # باید در کوئری خود به صورت زیر استفاده کنید :



SELECT *
FROM YourTable where gdate between #10/20/2006# and #10/15/2009#;


موفق باشی