SQL for date

Results 1 to 2 of 2

Thread: SQL for date

  1. #1
    The Shopkeeper Guest

    Default SQL for date

    Hi Group.<BR><BR>I&#039ve a database that contains events by shortdate. I&#039d like to display the events that are in the current month only.<BR><BR>Any idea how to build the SQL query. <BR><BR>Here&#039s one of many I&#039ve tried ...<BR><BR>"SELECT * FROM events WHERE " & datepart("M",1)&"= date"<BR><BR>where date is the database field name<BR><BR>Any suggests to shops@hertsweb.net<BR><BR>Cheers, Craig MacKenzie<BR>_____________________________<BR>Crai g MacKenzie<BR> Webmaster of hertsWEB -<BR>Connecting the Communities<BR>of Hertfordshire.<BR>Tel: 01920 424845 (eve)<BR>Web: www.hertsweb.org.uk<BR>Email: webmaster@hertsWEB.org.uk<BR>_____________________ ________

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: SQL for date

    SQL has a datepart function too (although the parameters are slightly different that VBScript&#039s). YOu can use that.<BR><BR>"SELECT * FROM events WHERE datepart(m,date) = " & datepart("M",now)<BR><BR>Something like that. I am a little unsure of the exact syntax for SQL&#039s datepart; be sure to check the SQL books online.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •